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

📄 xwiki.java

📁 xwiki 源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        setNotificationManager(new XWikiNotificationManager());        // Prepare the store        XWikiStoreInterface basestore;        setConfig(config);        String storeclass = Param("xwiki.store.class", "com.xpn.xwiki.store.XWikiRCSFileStore");        try {            Class[] classes = new Class[]{this.getClass(), context.getClass()};            Object[] args = new Object[]{this, context};            basestore = (XWikiStoreInterface) Class.forName(storeclass).getConstructor(classes).newInstance(args);        } catch (InvocationTargetException e) {            Object[] args = {storeclass};            throw new XWikiException(XWikiException.MODULE_XWIKI_STORE,                    XWikiException.ERROR_XWIKI_STORE_CLASSINVOCATIONERROR,                    "Cannot load store class {0}", e.getTargetException(), args);        } catch (Exception e) {            Object[] args = {storeclass};            throw new XWikiException(XWikiException.MODULE_XWIKI_STORE,                    XWikiException.ERROR_XWIKI_STORE_CLASSINVOCATIONERROR,                    "Cannot load store class {0}", e, args);        }        // Check if we need to use the cache store..        boolean nocache = "0".equals(Param("xwiki.store.cache", "1"));        if (!nocache) {            XWikiCacheStoreInterface cachestore = new XWikiCacheStore(basestore, context);            try {                String capacity = Param("xwiki.store.cache.capacity");                if (capacity != null)                    cachestore.setCacheCapacity(Integer.parseInt(capacity));            } catch (Exception e) {            }            try {                String capacity = Param("xwiki.store.cache.pageexistcapacity");                if (capacity != null)                    cachestore.setPageExistCacheCapacity(Integer.parseInt(capacity));            } catch (Exception e) {            }            setStore(cachestore);        } else            setStore(basestore);        // Prepare the Rendering Engine        setRenderingEngine(new XWikiRenderingEngine(this, context));        // Prepare the Plugin Engine        preparePlugins(context);        // Add a notification rule if the preference property plugin is modified        getNotificationManager().addNamedRule("XWiki.XWikiPreferences",                new PropertyChangedRule(this, "XWiki.XWikiPreferences", "plugin"));        // Make sure these classes exists        if (noupdate) {            getPrefsClass(context);            getUserClass(context);            getGroupClass(context);            getRightsClass(context);            getCommentsClass(context);            getSkinClass(context);            getGlobalRightsClass(context);            getStatsService(context);        }        String ro = Param ("xwiki.readonly", "no");        isReadOnly = ("yes".equalsIgnoreCase(ro) || "true".equalsIgnoreCase(ro) || "1".equalsIgnoreCase(ro));    }    private void preparePlugins(XWikiContext context) {        setPluginManager(new XWikiPluginManager(getXWikiPreference("plugins", context), context));        String plugins = Param("xwiki.plugins", "");        if (!plugins.equals("")) {            getPluginManager().addPlugins(StringUtils.split(plugins, " ,"), context);        }    }    public String getVersion() {        if (version == null) {            version = Param("xwiki.version", "");            String bnb = null;            try {                InputStream is = getResourceAsStream("/WEB-INF/version.properties");                XWikiConfig vprop = new XWikiConfig(is);                bnb = vprop.getProperty("build.number");            } catch (Exception e) {            }            if (bnb != null)                version = version + "." + bnb;        }        return version;    }    public URL getResource(String s) throws MalformedURLException {        return getEngineContext().getResource(s);    }    public InputStream getResourceAsStream(String s) throws MalformedURLException {        return getEngineContext().getResourceAsStream(s);    }    public String getResourceContent(String name) throws IOException {        InputStream is = null;        if (getEngineContext() != null) {            try {                is = getResourceAsStream(name);            } catch (Exception e) {            }        }        if (is == null)            return Util.getFileContent(new File(name));        return Util.getFileContent(new InputStreamReader(is));    }    public boolean resourceExists(String name) {        InputStream ris = null;        if (getEngineContext() != null) {            try {                ris = getResourceAsStream(name);                if (ris != null)                    return true;            } catch (IOException e) {            }        }        File file = new File(name);        return file.exists();    }    public XWikiConfig getConfig() {        return config;    }    public String getRealPath(String path) {        return getEngineContext().getRealPath(path);    }    public String Param(String key) {        return getConfig().getProperty(key);    }    public String ParamAsRealPath(String key) {        String param = Param(key);        try {            return getRealPath(param);        } catch (Exception e) {            return param;        }    }    public String ParamAsRealPath(String key, XWikiContext context) {        return ParamAsRealPath(key);    }    public String ParamAsRealPathVerified(String param) {        String path;        File fpath;        path = Param(param);        if (path == null)            return null;        fpath = new File(path);        if (fpath.exists()) {            return path;        }        path = getRealPath(path);        if (path == null)            return null;        fpath = new File(path);        if (fpath.exists()) {            return path;        } else {        }        return null;    }    public String Param(String key, String default_value) {        return getConfig().getProperty(key, default_value);    }    public long ParamAsLong(String key) {        String param = getConfig().getProperty(key);        return Long.parseLong(param);    }    public long ParamAsLong(String key, long default_value) {        try {            return ParamAsLong(key);        } catch (NumberFormatException e) {            return default_value;        }    }    public XWikiStoreInterface getStore() {        return store;    }    public void saveDocument(XWikiDocument doc, XWikiContext context) throws XWikiException {        getStore().saveXWikiDoc(doc, context);    }    public void saveDocument(XWikiDocument doc, XWikiDocument olddoc, XWikiContext context) throws XWikiException {        getStore().saveXWikiDoc(doc, context);        getNotificationManager().verify(doc, olddoc, XWikiDocChangeNotificationInterface.EVENT_CHANGE, context);    }    private XWikiDocument getDocument(XWikiDocument doc, XWikiContext context) throws XWikiException {        return getStore().loadXWikiDoc(doc, context);    }    public XWikiDocument getDocument(XWikiDocument doc, String revision, XWikiContext context) throws XWikiException {        XWikiDocument newdoc;        try {            if ((revision == null) || revision.equals("")) {                newdoc = new XWikiDocument(doc.getWeb(), doc.getName());            } else if (revision.equals(doc.getVersion())) {                newdoc = doc;            } else {                newdoc = getStore().loadXWikiDoc(doc, revision, context);            }        } catch (XWikiException e) {            if (revision.equals("1.1") || revision.equals("1.0"))                newdoc = new XWikiDocument(doc.getWeb(), doc.getName());            else                throw e;        }        return newdoc;    }    public XWikiDocument getDocument(String fullname, XWikiContext context) throws XWikiException {        String server = null, database = null;        try {            XWikiDocument doc = new XWikiDocument();            doc.setFullName(fullname, context);            server = doc.getDatabase();            if (server != null) {                database = context.getDatabase();                context.setDatabase(server);            }            doc = getDocument(doc, context);            return doc;        } finally {            if ((server != null) && (database != null)) {                context.setDatabase(database);            }        }    }    public XWikiDocument getDocument(String web, String fullname, XWikiContext context) throws XWikiException {        int i1 = fullname.lastIndexOf(".");        if (i1 != -1) {            String web2 = fullname.substring(0, i1);            String name = fullname.substring(i1 + 1);            if (name.equals(""))                name = "WebHome";            return getDocument(web2 + "." + name, context);        } else {            return getDocument(web + "." + fullname, context);        }    }    public XWikiDocument getDocumentFromPath(String path, XWikiContext context) throws XWikiException {        String web, name;        int i1 = path.indexOf("/", 1);        int i2 = path.indexOf("/", i1 + 1);        int i3 = path.indexOf("/", i2 + 1);        web = path.substring(i1 + 1, i2);        if (i3 == -1)            name = path.substring(i2 + 1);        else            name = path.substring(i2 + 1, i3);        if (name.equals(""))            name = "WebHome";        web = Utils.decode(web, context);        name = Utils.decode(name, context);        return getDocument(web + "." + name, context);    }    public XWikiRenderingEngine getRenderingEngine() {        return renderingEngine;    }    public void setRenderingEngine(XWikiRenderingEngine renderingEngine) {        this.renderingEngine = renderingEngine;    }    public MetaClass getMetaclass() {        return metaclass;    }    public void setMetaclass(MetaClass metaclass) {        this.metaclass = metaclass;    }    public static String getFormEncoded(String content) {        Filter filter = new CharacterFilter();        filter.removeAttribute("'");        String scontent = filter.process(content);        return scontent;    }    public static String getURLEncoded(String content) {        try {            return URLEncoder.encode(content, "UTF-8");        } catch (UnsupportedEncodingException e) {            return content;        }    }    public static String getXMLEncoded(String content) {        Filter filter = new CharacterFilter();        String scontent = filter.process(content);        return scontent;    }    public static String getTextArea(String content, XWikiContext context) {        Filter filter = new CharacterFilter();        filter.removeAttribute("'");        String scontent = filter.process(content);        textarea textarea = new textarea();        textarea.setFilter(filter);        int rows = 25;        try {            rows = context.getWiki().getUserPreferenceAsInt("editbox_height", context);        } catch (Exception e) {        }        textarea.setRows(rows);        int cols = 80;        try {            context.getWiki().getUserPreferenceAsInt("editbox_width", context);        } catch (Exception e) {        }        textarea.setCols(cols);        textarea.setName("content");        textarea.addElement(scontent);

⌨️ 快捷键说明

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