1 5 6 11 12 package com.raptus.owxv3; 13 14 import java.io.File ; 15 import java.util.*; 16 17 import org.jdom.*; 18 import org.jdom.input.SAXBuilder; 19 20 21 25 public class XMLVModuleManager extends Object 26 { 27 protected String directoryWEBINF; 28 protected static Virtualhost _vhost=null; 29 30 public Virtualhost getVirtualhost() 31 { 32 return _vhost; 33 } 34 35 36 public XMLVModuleManager() 37 { 38 } 40 41 44 protected static XMLVModuleManager _instance = null; 45 46 protected static Element root = null; 47 48 51 public static XMLVModuleManager getInstance() 52 { 53 if(_instance == null) 54 _instance = new XMLVModuleManager(); 55 56 return _instance; 57 } 58 59 62 public boolean initialize(StrutsOWXPlugIn plugin) 63 { 64 directoryWEBINF = plugin.getWEBINFDir(); 68 70 try 71 { 72 SAXBuilder builder = new SAXBuilder(false); 74 String file=directoryWEBINF+"/"+"owx-config.xml"; 75 Document doc = builder.build(new File (file)); 76 root = doc.getRootElement(); 77 79 List categories = root.getChildren("virtualhost"); 82 Iterator i = categories.iterator(); 83 84 while (i.hasNext()) 85 { 86 Element vhost = (Element) i.next(); 87 if(vhost != null) 88 { 89 if(!initialiseVirtualHost(vhost)) 90 { 91 return false; 92 } 93 } 94 } 95 } 96 catch(org.jdom.JDOMException ex) 97 { 98 ex.printStackTrace(); 99 } 100 102 103 return true; 104 } 105 106 109 public boolean initialiseVirtualHost(Element e) 110 { 111 122 _vhost = new Virtualhost(e.getAttribute("identification").getValue(), 123 e.getAttribute("webmaster").getValue(), 124 e.getAttribute("hostname").getValue(), 125 e.getAttribute("multiuser").getValue().equals("true") 126 ); 127 128 List gresl = e.getChildren("global_resource"); 129 Iterator i = gresl.iterator(); 130 131 while (i.hasNext()) 132 { 133 Element gres = (Element) i.next(); 134 if(gres != null) 135 { 136 if(!initialiseGlobalResource(gres)) 137 { 138 return false; 139 } 140 } 141 } 142 return true; 144 } 145 146 public boolean initialiseGlobalResource(Element e) 147 { 148 return true; 150 } 151 } 152 | Popular Tags |