1 20 package org.jahia.data.webapps; 21 22 23 import java.util.Vector ; 24 25 import org.jahia.data.xml.JahiaXmlDocument; 26 import org.jahia.exceptions.JahiaException; 27 import org.jahia.utils.xml.XMLParser; 28 import org.w3c.dom.Element ; 29 import org.w3c.dom.Node ; 30 31 32 51 public class Application_Xml extends JahiaXmlDocument { 52 53 54 private String m_DisplayName; 55 56 private String m_desc; 57 59 private Vector m_WebComponents = new Vector (); 60 61 62 67 public Application_Xml (String docPath) throws JahiaException 68 { 69 super(docPath); 70 } 71 72 73 79 public Application_Xml (String docPath, org.xml.sax.helpers.ParserAdapter parser) 80 throws JahiaException { 81 super(docPath,parser); 82 } 83 84 85 89 public void extractDocumentData() throws JahiaException { 90 91 93 if (m_XMLDocument == null) { 94 95 throw new JahiaException( "Application_Xml", 96 "Parsed application.xml document is null", 97 JahiaException.ERROR_SEVERITY, 98 JahiaException.SERVICE_ERROR); 99 } 100 101 102 if (!m_XMLDocument.hasChildNodes()) { 103 104 throw new JahiaException( "Application_Xml", 105 "Main document node has no children", 106 JahiaException.ERROR_SEVERITY, 107 JahiaException.SERVICE_ERROR); 108 } 109 110 111 Element docElNode = (Element ) m_XMLDocument.getDocumentElement(); 113 114 if (!docElNode.getNodeName().equalsIgnoreCase("application")) { 115 116 throw new JahiaException( "Invalid XML format", 117 "application tag is not present as starting tag in file", 118 JahiaException.ERROR_SEVERITY, 119 JahiaException.SERVICE_ERROR); 120 } 121 122 123 Vector modNodes = XMLParser.getChildNodes(docElNode,"module"); 125 Node nodeItem = null; 126 Node webNode = null; 127 Node webURINode = null; 128 Node contextNode = null; 129 Node textNode = null; 130 String webURI = null; 131 String contextRoot = null; 132 int size = modNodes.size(); 133 134 for ( int i=0 ; i<size; i++ ){ 135 136 nodeItem = (Node )modNodes.get(i); 137 138 webNode = XMLParser.nextChildOfTag(nodeItem,"web"); 139 if (webNode != null ){ 140 webURINode = XMLParser.nextChildOfTag(webNode,"web-uri"); 141 if (webURINode != null ){ 142 textNode = webURINode.getFirstChild(); 143 if ( textNode != null ){ 144 webURI = textNode.getNodeValue().trim(); 145 } 146 } 147 148 contextNode = XMLParser.nextChildOfTag(webNode,"context-root"); 149 if (contextNode != null ){ 150 textNode = contextNode.getFirstChild(); 151 if ( textNode != null){ 152 contextRoot = textNode.getNodeValue().trim(); 153 } else { 154 contextRoot = ""; 155 } 156 157 } 158 159 if ( (webURI != null) && (webURI.length()>0) && contextRoot != null) { 160 161 Web_Component webComp = new Web_Component( webURI, contextRoot ); 162 163 166 m_WebComponents.add(webComp); 167 } 168 } 169 } 170 171 } 173 174 175 180 public String getDisplayName(){ 181 182 return m_DisplayName; 183 } 184 185 186 190 protected void setDisplayName(String name){ 191 192 m_DisplayName = name; 193 } 194 195 200 public String getdesc(){ 201 202 return m_desc; 203 } 204 205 206 210 protected void setdesc(String descr){ 211 212 m_desc = descr; 213 } 214 215 216 221 public Vector getWebComponents(){ 222 223 return m_WebComponents; 224 225 } 226 227 228 229 230 231 232 } | Popular Tags |