📄 application_xml.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//////// Application_Xml//// NK 29.01.2001////package org.jahia.data.webapps;import java.io.*;import java.util.*;import java.util.zip.*;//import com.sun.xml.tree.*;//import com.sun.xml.parser.Parser;import org.xml.sax.helpers.ParserAdapter;import org.w3c.dom.*;//import org.xml.sax.*;import org.jahia.exceptions.*;import org.jahia.utils.zip.*; // JahiaarHandlerimport org.jahia.utils.*; // JahiaCmdExecimport org.jahia.data.xml.*; // JahiaXmlDocumentimport org.jahia.utils.xml.*; // JahiaConsole, XMLParser/** * Holds Informations about the Application deployment descriptors file * application.xml ( J2EE Standard ) * * <application> * <display-name>filemanager.ear</display-name> * <desc>Application desc</desc> * <module> * <web> * <web-uri>war-ic.war</web-uri> * <context-root>filemanager</context-root> * </web> * </module> * </application> * * * @author Khue ng * @version 1.0 */public class Application_Xml extends JahiaXmlDocument { /** The J2EE Application Display Name **/ private String m_DisplayName; /** The J2EE Application desc **/ private String m_desc; /** The list of Web Components * * @associates Web_Component*/ private Vector m_WebComponents = new Vector(); /** * Constructor * * @param (String) path, the full path to the application.xml file */ public Application_Xml (String docPath) throws JahiaException { super(docPath); } /** * Constructor using a gived parser * * @param (String) path, the full path to a xml file * @param (Parser) parser, the parser to use */ public Application_Xml (String docPath, org.xml.sax.helpers.ParserAdapter parser) throws JahiaException { super(docPath,parser); } /** * Extracts data from the application.xml file. Build the JahiaWebAppsWarPackage object * to store extracted data */ public void extractDocumentData() throws JahiaException { //JahiaConsole.println("Application_Xml::extractDocumentData","started"); if (m_XMLDocument == null) { throw new JahiaException( "Application_Xml", "Parsed application.xml document is null", JahiaException.ERROR, JahiaException.SERVICE_ERROR); } if (!m_XMLDocument.hasChildNodes()) { throw new JahiaException( "Application_Xml", "Main document node has no children", JahiaException.ERROR, JahiaException.SERVICE_ERROR); } // get application node Element docElNode = (Element) m_XMLDocument.getDocumentElement(); if (!docElNode.getNodeName().equalsIgnoreCase("application")) { throw new JahiaException( "Invalid XML format", "application tag is not present as starting tag in file", JahiaException.ERROR, JahiaException.SERVICE_ERROR); } // get module nodes Vector modNodes = XMLParser.getChildNodes(docElNode,"module"); Node nodeItem = null; Node webNode = null; Node webURINode = null; Node contextNode = null; Node textNode = null; String webURI = null; String contextRoot = null; int size = modNodes.size(); for ( int i=0 ; i<size; i++ ){ nodeItem = (Node)modNodes.get(i); webNode = XMLParser.nextChildOfTag(nodeItem,"web"); if (webNode != null ){ webURINode = XMLParser.nextChildOfTag(webNode,"web-uri"); if (webURINode != null ){ textNode = webURINode.getFirstChild(); if ( textNode != null ){ webURI = textNode.getNodeValue().trim(); } } contextNode = XMLParser.nextChildOfTag(webNode,"context-root"); if (contextNode != null ){ textNode = contextNode.getFirstChild(); if ( textNode != null){ contextRoot = textNode.getNodeValue().trim(); } else { contextRoot = ""; } } if ( (webURI != null) && (webURI.length()>0) && contextRoot != null) { Web_Component webComp = new Web_Component( webURI, contextRoot ); //JahiaConsole.println(">>"," Web Component Web URI :" + webComp.getWebURI()); //JahiaConsole.println(">>"," Context Root :" + webComp.getContextRoot()); m_WebComponents.add(webComp); } } } //JahiaConsole.println("Application_Xml::extractDocumentData","extraction done"); } /** * Return the Display Name * * @return (String) the display name of the Application */ public String getDisplayName(){ return m_DisplayName; } /** * Set the DisplayName * @param (String) the display name of the webApp */ protected void setDisplayName(String name){ m_DisplayName = name; } /** * Return the Web App desc * * @return (String) the desc */ public String getdesc(){ return m_desc; } /** * Set the desc * @param (String) the desc */ protected void setdesc(String descr){ m_desc = descr; } /** * Return the list of Web Components * * @return (Vector) list of Web Components */ public Vector getWebComponents(){ return m_WebComponents; }} // end Application_Xml
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -