📄 adminconsole.java
字号:
} catch (Exception ignored) { // Ignore. } // Load other admin-sidebar.xml files from the classpath ClassLoader[] classLoaders = getClassLoaders(); for (int i=0; i<classLoaders.length; i++) { URL url = null; try { if (classLoaders[i] != null) { Enumeration e = classLoaders[i].getResources("/META-INF/admin-sidebar.xml"); while (e.hasMoreElements()) { url = (URL)e.nextElement(); try { in = url.openStream(); addModel("admin", in); } finally { try { if (in != null) { in.close(); } } catch (Exception ignored) { // Ignore. } } } } } catch (Exception e) { String msg = "Failed to load admin-sidebar.xml"; if (url != null) { msg += " from resource: " + url.toString(); } Log.warn(msg, e); } } rebuildModel(); } /** * Rebuilds the generated model. */ private static synchronized void rebuildModel() { Document doc = DocumentFactory.getInstance().createDocument(); generatedModel = coreModel.createCopy(); doc.add(generatedModel); // Add in all overrides. for (Element element : overrideModels.values()) { // See if global settings are overriden. Element appName = (Element)element.selectSingleNode("//adminconsole/global/appname"); if (appName != null) { Element existingAppName = (Element)generatedModel.selectSingleNode( "//adminconsole/global/appname"); existingAppName.setText(appName.getText()); if (appName.attributeValue("plugin") != null) { existingAppName.addAttribute("plugin", appName.attributeValue("plugin")); } } Element appLogoImage = (Element)element.selectSingleNode("//adminconsole/global/logo-image"); if (appLogoImage != null) { Element existingLogoImage = (Element)generatedModel.selectSingleNode( "//adminconsole/global/logo-image"); existingLogoImage.setText(appLogoImage.getText()); if (appLogoImage.attributeValue("plugin") != null) { existingLogoImage.addAttribute("plugin", appLogoImage.attributeValue("plugin")); } } Element appLoginImage = (Element)element.selectSingleNode("//adminconsole/global/login-image"); if (appLoginImage != null) { Element existingLoginImage = (Element)generatedModel.selectSingleNode( "//adminconsole/global/login-image"); existingLoginImage.setText(appLoginImage.getText()); if (appLoginImage.attributeValue("plugin") != null) { existingLoginImage.addAttribute("plugin", appLoginImage.attributeValue("plugin")); } } Element appVersion = (Element)element.selectSingleNode("//adminconsole/global/version"); if (appVersion != null) { Element existingVersion = (Element)generatedModel.selectSingleNode( "//adminconsole/global/version"); if (existingVersion != null) { existingVersion.setText(appVersion.getText()); if (appVersion.attributeValue("plugin") != null) { existingVersion.addAttribute("plugin", appVersion.attributeValue("plugin")); } } else { ((Element)generatedModel.selectSingleNode( "//adminconsole/global")).add(appVersion.createCopy()); } } // Tabs for (Iterator i=element.selectNodes("//tab").iterator(); i.hasNext(); ) { Element tab = (Element)i.next(); String id = tab.attributeValue("id"); Element existingTab = getElemnetByID(id); // Simple case, there is no existing tab with the same id. if (existingTab == null) { // Make sure that the URL on the tab is set. If not, default to the // url of the first item. if (tab.attributeValue("url") == null) { Element firstItem = (Element)tab.selectSingleNode( "//item[@url]"); if (firstItem != null) { tab.addAttribute("url", firstItem.attributeValue("url")); } } generatedModel.add(tab.createCopy()); } // More complex case -- a tab with the same id already exists. // In this case, we have to overrite only the difference between // the two elements. else { overrideTab(existingTab, tab); } } } // Special case: show an informational tab about Wildfire Enterprise if Enterprise // is not installed and if the user has not chosen to hide tab. PluginManager pluginManager = XMPPServer.getInstance().getPluginManager(); boolean pluginExists = pluginManager != null && pluginManager.isPluginDownloaded( "enterprise.jar"); if (!pluginExists && JiveGlobals.getBooleanProperty("enterpriseInfoEnabled", true)) { Element enterprise = generatedModel.addElement("tab"); enterprise.addAttribute("id", "tab-enterprise"); enterprise.addAttribute("name", "Enterprise"); enterprise.addAttribute("url", "enterprise-info.jsp"); enterprise.addAttribute("description", "Click for Enterprise information."); Element sidebar = enterprise.addElement("sidebar"); sidebar.addAttribute("id", "sidebar-enterprise-info"); sidebar.addAttribute("name", "Wildfire Enterprise"); Element item = sidebar.addElement("item"); item.addAttribute("id", "enterprise-info"); item.addAttribute("name", "Try Enterprise"); item.addAttribute("url", "enterprise-info.jsp"); item.addAttribute("description", "Wildfire Enterprise overview inforation"); } } private static void overrideTab(Element tab, Element overrideTab) { // Override name, url, description. if (overrideTab.attributeValue("name") != null) { tab.addAttribute("name", overrideTab.attributeValue("name")); } if (overrideTab.attributeValue("url") != null) { tab.addAttribute("url", overrideTab.attributeValue("url")); } if (overrideTab.attributeValue("description") != null) { tab.addAttribute("description", overrideTab.attributeValue("description")); } if (overrideTab.attributeValue("plugin") != null) { tab.addAttribute("plugin", overrideTab.attributeValue("plugin")); } // Override sidebar items. for (Iterator i=overrideTab.elementIterator(); i.hasNext(); ) { Element sidebar = (Element)i.next(); String id = sidebar.attributeValue("id"); Element existingSidebar = getElemnetByID(id); // Simple case, there is no existing sidebar with the same id. if (existingSidebar == null) { tab.add(sidebar.createCopy()); } // More complex case -- a sidebar with the same id already exists. // In this case, we have to overrite only the difference between // the two elements. else { overrideSidebar(existingSidebar, sidebar); } } } private static void overrideSidebar(Element sidebar, Element overrideSidebar) { // Override name. if (overrideSidebar.attributeValue("name") != null) { sidebar.addAttribute("name", overrideSidebar.attributeValue("name")); } if (overrideSidebar.attributeValue("plugin") != null) { sidebar.addAttribute("plugin", overrideSidebar.attributeValue("plugin")); } // Override entries. for (Iterator i=overrideSidebar.elementIterator(); i.hasNext(); ) { Element entry = (Element)i.next(); String id = entry.attributeValue("id"); Element existingEntry = getElemnetByID(id); // Simple case, there is no existing sidebar with the same id. if (existingEntry == null) { sidebar.add(entry.createCopy()); } // More complex case -- an entry with the same id already exists. // In this case, we have to overrite only the difference between // the two elements. else { overrideEntry(existingEntry, entry); } } } private static void overrideEntry(Element entry, Element overrideEntry) { // Override name. if (overrideEntry.attributeValue("name") != null) { entry.addAttribute("name", overrideEntry.attributeValue("name")); } if (overrideEntry.attributeValue("url") != null) { entry.addAttribute("url", overrideEntry.attributeValue("url")); } if (overrideEntry.attributeValue("description") != null) { entry.addAttribute("description", overrideEntry.attributeValue("description")); } if (overrideEntry.attributeValue("plugin") != null) { entry.addAttribute("plugin", overrideEntry.attributeValue("plugin")); } // Override any sidebars contained in the entry. for (Iterator i=overrideEntry.elementIterator(); i.hasNext(); ) { Element sidebar = (Element)i.next(); String id = sidebar.attributeValue("id"); Element existingSidebar = getElemnetByID(id); // Simple case, there is no existing sidebar with the same id. if (existingSidebar == null) { entry.add(sidebar.createCopy()); } // More complex case -- a sidebar with the same id already exists. // In this case, we have to overrite only the difference between // the two elements. else { overrideSidebar(existingSidebar, sidebar); } } } /** * Returns an array of class loaders to load resources from. * * @return an array of class loaders to load resources from. */ private static ClassLoader[] getClassLoaders() { ClassLoader[] classLoaders = new ClassLoader[3]; classLoaders[0] = AdminConsole.class.getClass().getClassLoader(); classLoaders[1] = Thread.currentThread().getContextClassLoader(); classLoaders[2] = ClassLoader.getSystemClassLoader(); return classLoaders; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -