⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xwiki.java

📁 xwiki 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** * =================================================================== * * Copyright (c) 2003 Ludovic Dubost, All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details, published at * http://www.gnu.org/copyleft/gpl.html or in gpl.txt in the * root folder of this distribution. * * User: ludovic * Date: 26 f�vr. 2004 * Time: 17:50:47 */package com.xpn.xwiki.api;import com.sun.image.codec.jpeg.JPEGCodec;import com.sun.image.codec.jpeg.JPEGImageEncoder;import com.xpn.xwiki.XWikiContext;import com.xpn.xwiki.XWikiException;import com.xpn.xwiki.web.Utils;import com.xpn.xwiki.plugin.calendar.CalendarPlugin;import com.xpn.xwiki.plugin.calendar.CalendarPlugin;import com.xpn.xwiki.render.XWikiVelocityRenderer;import com.xpn.xwiki.stats.impl.DocumentStats;import com.xpn.xwiki.stats.api.XWikiStatsService;import com.xpn.xwiki.doc.XWikiDocument;import com.xpn.xwiki.objects.meta.MetaClass;import com.xpn.xwiki.objects.BaseObject;import org.apache.commons.jrcs.diff.Chunk;import org.apache.velocity.VelocityContext;import java.awt.image.BufferedImage;import java.io.IOException;import java.io.OutputStream;import java.util.*;import java.net.MalformedURLException;public class XWiki extends Api {    private com.xpn.xwiki.XWiki xwiki;    public XWiki(com.xpn.xwiki.XWiki xwiki, XWikiContext context) {       super(context);       this.xwiki = xwiki;    }    public com.xpn.xwiki.XWiki getXWiki() {        if (checkProgrammingRights())            return xwiki;        else            return null;    }     public String getVersion() {          return xwiki.getVersion();     }     public String getRequestURL() throws XWikiException {         return com.xpn.xwiki.XWiki.getRequestURL(context.getRequest()).toString();     }     /**      * Loads an Document from the database. Rights are checked before sending back the document.      * @param fullname Fullname of the XWiki document to be loaded      * @return a Document object or null if it is not accessible      * @throws XWikiException      */     public Document getDocument(String fullname) throws XWikiException {         XWikiDocument doc = xwiki.getDocument(fullname, context);         if (xwiki.getRightService().hasAccessLevel("view", context.getUser(), doc.getFullName(), context)==false) {                    return null;                }         Document newdoc = new Document(doc, context);         return newdoc;     }    /**     * Returns wether a document exists or not     * @param fullname Fullname of the XWiki document to be loaded     * @return true if the document exists, false if not     * @throws XWikiException     */    public boolean exists(String fullname) throws XWikiException {        return xwiki.exists(fullname, context);    }    /**     * Verify the rights the current user has on a document     * @param docname fullname of the document     * @param right right to check ("view", "edit", "admin", "delete")     * @return true if it exists     */    public boolean checkAccess(String docname, String right) {        try {            XWikiDocument doc =new XWikiDocument();            doc.setFullName(docname, context);            return context.getWiki().checkAccess(right, doc, context);        } catch (XWikiException e) {            return false;        }    }    /**     * Loads an Document from the database. Rights are checked before sending back the document.     *     * @param web  Space to use in case no space is defined in the fullname     * @param fullname Fullname or relative name of the document to load     * @return a Document object or null if it is not accessible     * @throws XWikiException     */     public Document getDocument(String web, String fullname) throws XWikiException {         XWikiDocument doc = xwiki.getDocument(web, fullname, context);         if (xwiki.getRightService().hasAccessLevel("view", context.getUser(), doc.getFullName(), context)==false) {                    return null;                }         Document newdoc = new Document(doc, context);         return newdoc;     }    /**     * Load a specific revision of a document     * @param doc Document for which to load a specific revision     * @param rev Revision number     * @return  Specific revision of a document     * @throws XWikiException     */    public Document getDocument(Document doc, String rev) throws XWikiException {        if ((doc==null)||(doc.getDoc()==null))            return null;        if (xwiki.getRightService().hasAccessLevel("view", context.getUser(), doc.getFullName(), context)==false) {                    // Finally we return null, otherwise showing search result is a real pain                   return null;               }        try {            XWikiDocument revdoc = xwiki.getDocument(doc.getDoc(), rev, context);            Document newdoc = new Document(revdoc, context);            return newdoc;        } catch (Exception e) {            // Can't read versioned document            e.printStackTrace();            return null;        }    }    /**     * Transform a text in a form compatible text     * @param content text to transform     * @return  encoded result     */     public String getFormEncoded(String content) {        return xwiki.getFormEncoded(content);     }    /**     * Transform a text in a URL compatible text     * @param content text to transform     * @return  encoded result     */    public String getURLEncoded(String content) {       return xwiki.getURLEncoded(content);    }    /**     * Transform a text in a XML compatible text     * @param content text to transform     * @return  encoded result     */     public String getXMLEncoded(String content) {        return xwiki.getXMLEncoded(content);     }    /**     * Output content in the edit content textarea     * @param content content to output     * @return the textarea text content     */     public String getTextArea(String content) {        return xwiki.getTextArea(content, context);     }    /**     * Output content in the edit content htmlarea     * @param content content to output     * @return the htmlarea text content     */    public String getHTMLArea(String content) {        return xwiki.getHTMLArea(content, context);    }    /**     * Get the list of available classes in the wiki     * @return list of classes names     * @throws XWikiException     */    public List getClassList() throws XWikiException {        return xwiki.getClassList(context);    }    /**     * Get the global MetaClass object     * @return MetaClass object     */    public MetaClass getMetaclass() {        return xwiki.getMetaclass();    }    public List search(String wheresql) throws XWikiException {        return xwiki.search(wheresql, context);    }    public List search(String wheresql, int nb, int start) throws XWikiException {        return xwiki.search(wheresql, nb, start, context);    }    public List searchDocuments(String wheresql) throws XWikiException {        return xwiki.getStore().searchDocumentsNames(wheresql, context);    }    public List searchDocuments(String wheresql, int nb, int start) throws XWikiException {        return xwiki.getStore().searchDocumentsNames(wheresql, nb, start, context);    }    public List searchDocuments(String wheresql, int nb, int start, String selectColumns) throws XWikiException {         return xwiki.getStore().searchDocumentsNames(wheresql, nb, start, selectColumns, context);     }    public List searchDocuments(String wheresql, boolean distinctbylanguage) throws XWikiException {        return xwiki.getStore().searchDocuments(wheresql, context);    }    public List searchDocuments(String wheresql, boolean distinctbylanguage, int nb, int start) throws XWikiException {        return xwiki.getStore().searchDocuments(wheresql, nb, start, context);    }    public String parseContent(String content) {        return xwiki.parseContent(content, context);    }    public String parseTemplate(String template) {            return xwiki.parseTemplate(template, context);        }    /**     * Designed to include dynamic content, such as Servlets or JSPs, inside Velocity     * templates; works by creating a RequestDispatcher, buffering the output,     * then returning it as a string.     *     * @author LBlaze     */    public String invokeServletAndReturnAsString(String url) {        return xwiki.invokeServletAndReturnAsString(url, context);    }    public String getSkinFile(String filename) {        return xwiki.getSkinFile(filename, context);    }    public String getSkin() {        return xwiki.getSkin(context);    }    public String getBaseSkin() {        return xwiki.getBaseSkin(context);    }    public String getWebCopyright() {        return xwiki.getWebCopyright(context);    }    public String getXWikiPreference(String prefname) {        return xwiki.getXWikiPreference(prefname, context);    }    public String getXWikiPreference(String prefname, String default_value) {        return xwiki.getXWikiPreference(prefname, default_value, context);    }    public String getWebPreference(String prefname) {        return xwiki.getWebPreference(prefname, context);    }    public String getWebPreference(String prefname, String default_value) {        return xwiki.getWebPreference(prefname, default_value, context);    }    public long getXWikiPreferenceAsLong(String prefname, long default_value) {        return xwiki.getXWikiPreferenceAsLong(prefname, default_value, context);    }    public long getXWikiPreferenceAsLong(String prefname) {        return xwiki.getXWikiPreferenceAsLong(prefname, context);    }    public long getWebPreferenceAsLong(String prefname, long default_value) {        return xwiki.getWebPreferenceAsLong(prefname, default_value, context);    }    public long getWebPreferenceAsLong(String prefname) {        return xwiki.getWebPreferenceAsLong(prefname, context);    }    public int getXWikiPreferenceAsInt(String prefname, int default_value) {        return xwiki.getXWikiPreferenceAsInt(prefname, default_value, context);    }    public int getXWikiPreferenceAsInt(String prefname) {        return xwiki.getXWikiPreferenceAsInt(prefname, context);    }    public int getWebPreferenceAsInt(String prefname, int default_value) {        return xwiki.getWebPreferenceAsInt(prefname, default_value, context);    }    public int getWebPreferenceAsInt(String prefname) {        return xwiki.getWebPreferenceAsInt(prefname, context);    }    public String getUserPreference(String prefname) {        return xwiki.getUserPreference(prefname, context);    }    public String getUserPreferenceFromCookie(String prefname) {        return xwiki.getUserPreferenceFromCookie(prefname, context);    }    public String getLanguagePreference() {        return xwiki.getLanguagePreference(context);    }    public boolean isVirtual() {        return xwiki.isVirtual();    }    public boolean isMultiLingual() {        return xwiki.isMultiLingual(context);    }    public void flushCache() {        xwiki.flushCache();    }    public int createUser() throws XWikiException {        return createUser(false, "edit");    }    public int createUser(boolean withValidation) throws XWikiException {        return createUser(withValidation, "edit");    }    public int createUser(boolean withValidation, String userRights) throws XWikiException {        boolean registerRight;        try {            if (checkProgrammingRights()) {                registerRight = true;            } else {                registerRight = xwiki.getRightService().hasAccessLevel("register", context.getUser(),                        "XWiki.XWikiPreferences", context);            }            if (registerRight)                return xwiki.createUser(withValidation, userRights, context);            else                return -1;        } catch (Exception e) {            e.printStackTrace();            return -2;        }    }    public int createNewWiki(String wikiName, String wikiUrl, String wikiAdmin,                             String baseWikiName, boolean failOnExist) throws XWikiException {                return createNewWiki(wikiName, wikiUrl, wikiAdmin, baseWikiName, "", null, failOnExist);    }    public int createNewWiki(String wikiName, String wikiUrl, String wikiAdmin,                             String baseWikiName, String description, boolean failOnExist) throws XWikiException {                return createNewWiki(wikiName, wikiUrl, wikiAdmin, baseWikiName, description, null, failOnExist);    }    public int createNewWiki(String wikiName, String wikiUrl, String wikiAdmin,                             String baseWikiName, String description, String language, boolean failOnExist) throws XWikiException {        if (checkProgrammingRights())            return xwiki.createNewWiki(wikiName, wikiUrl, wikiAdmin, baseWikiName, description, language, failOnExist, context);        else return -1;    }    public int validateUser(boolean withConfirmEmail) throws XWikiException {        return xwiki.validateUser(withConfirmEmail, context);    }    public void sendMessage(String sender, String recipient, String message) throws XWikiException {        if (checkProgrammingRights())            xwiki.sendMessage(sender, recipient, message, context);    }    public void sendMessage(String sender, String[] recipient, String message) throws XWikiException {        if (checkProgrammingRights())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -