1 4 package cve.util; 5 6 import java.io.*; 7 import java.util.*; 8 9 import org.jdom.*; 10 import org.jdom.input.SAXBuilder; 11 import org.jdom.output.XMLOutputter; 12 13 import org.apache.log4j.Logger; 14 15 import cve.staticLayout.Cve; 16 17 26 public final class ConfigurationRead { 27 28 31 static public String getCveRoot() { 32 Cve.errLog.debug(""); 33 Element rootXml=ConfigurationRead(); 34 Element ele=rootXml.getChild("cveRoot"); 35 String cveRoot=(String )ele.getAttributeValue("name"); 36 return cveRoot; 37 } 38 39 43 static public String getCveVCARWRoot() { 44 Cve.errLog.debug(""); 45 Element rootXml=ConfigurationRead(); 46 Element ele=rootXml.getChild("cveVCARWRoot"); 47 String cveVCARWRoot=(String )ele.getAttributeValue("name"); 48 return cveVCARWRoot; 49 } 50 51 55 static public String getCveWSpeRoot() { 56 Cve.errLog.debug(""); 57 Element rootXml=ConfigurationRead(); 58 Element ele=rootXml.getChild("cveWSpeRoot"); 59 String cveWSpeRoot=(String )ele.getAttributeValue("name"); 60 return cveWSpeRoot; 61 } 62 63 67 static public String getCveWSpeSemantic() { 68 Cve.errLog.debug(""); 69 Element rootXml=ConfigurationRead(); 70 Element ele=rootXml.getChild("cveWSpeSemantic"); 71 String cveWSpeSemantic=(String )ele.getAttributeValue("name"); 72 return cveWSpeSemantic; 73 } 74 75 79 static public String getCveWSpeSentence() { 80 Cve.errLog.debug(""); 81 Element rootXml=ConfigurationRead(); 82 Element ele=rootXml.getChild("cveWSpeSentence"); 83 String cveWSpeSentence=(String )ele.getAttributeValue("name"); 84 return cveWSpeSentence; 85 } 86 87 91 static public String getIntSemTranslation() { 92 Cve.errLog.debug(""); 93 Element rootXml=ConfigurationRead(); 94 Element ele=rootXml.getChild("intSemTranslation"); 95 String intSemTranslation=(String )ele.getAttributeValue("name"); 96 return intSemTranslation; 97 } 98 99 102 static public String getEnvironmentTitle() { 103 Cve.errLog.debug(""); 104 Element rootXml=ConfigurationRead(); 105 Element ele=rootXml.getChild("cveChoiceEnvironment"); 106 String title=(String )ele.getAttributeValue("name"); 107 return title; 108 } 109 110 113 static public Collection getEnvironmentContainer() { 114 Cve.errLog.debug(""); 115 Vector app=new Vector(); 116 Element rootXml=ConfigurationRead(); 117 Element ele=rootXml.getChild("cveChoiceEnvironment"); 118 java.util.List containerEnv=ele.getChildren(); 119 Iterator itContainer=containerEnv.iterator(); 120 if (itContainer!=null){ 121 while (itContainer.hasNext()){ 122 Element newEle=(Element)itContainer.next(); 123 String containerName=(String )newEle.getAttributeValue("name"); 124 app.add(containerName); 125 } 126 } 127 return app; 128 } 129 130 135 static public List getEnvironmentItem(int index) { 136 Cve.errLog.debug(""); 137 Vector app=new Vector(); 138 Element rootXml=ConfigurationRead(); 139 Element ele=rootXml.getChild("cveChoiceEnvironment"); 140 java.util.List containerEnv=ele.getChildren(); 142 Iterator itContainer=containerEnv.iterator(); 143 int cont=0; 144 if (itContainer!=null){ while (itContainer.hasNext()){ 146 Element newEle=(Element)itContainer.next(); 147 if (cont==index){ java.util.List items=newEle.getChildren(); 149 Iterator itItem=items.iterator(); 150 if (itItem!=null){ 151 while (itItem.hasNext()){ Element newItem=(Element)itItem.next(); 153 String itemName=(String )newItem.getAttributeValue("name"); 154 app.add(itemName); 155 } 156 } 157 } 158 cont++; 159 } 160 } 161 return app; 162 } 163 164 171 static public List getEnvironmentItemClass(int index) { 172 Cve.errLog.debug(""); 173 Vector app=new Vector(); 174 Element rootXml=ConfigurationRead(); 175 Element ele=rootXml.getChild("cveChoiceEnvironment"); 176 java.util.List containerEnv=ele.getChildren(); 178 Iterator itContainer=containerEnv.iterator(); 179 int cont=0; 180 if (itContainer!=null){ while (itContainer.hasNext()){ 182 Element newEle=(Element)itContainer.next(); 183 if (cont==index){ java.util.List items=newEle.getChildren(); 185 Iterator itItem=items.iterator(); 186 if (itItem!=null){ 187 while (itItem.hasNext()){ Element newItem=(Element)itItem.next(); 189 String itemName=(String )newItem.getAttributeValue("class"); 190 app.add(itemName); 191 } 192 } 193 } 194 cont++; 195 } 196 } 197 return app; 198 } 199 200 208 static public List getEnvironmentItemIcon(int index) { 209 Cve.errLog.debug(""); 210 Vector app=new Vector(); 211 Element rootXml=ConfigurationRead(); 212 Element ele=rootXml.getChild("cveChoiceEnvironment"); 213 java.util.List containerEnv=ele.getChildren(); 215 Iterator itContainer=containerEnv.iterator(); 216 int cont=0; 217 if (itContainer!=null) { while (itContainer.hasNext()) { 219 Element newEle=(Element)itContainer.next(); 220 if (cont==index){ java.util.List items=newEle.getChildren(); 222 Iterator itItem=items.iterator(); 223 if (itItem!=null) { 224 while (itItem.hasNext()){ Element newItem=(Element)itItem.next(); 226 String itemName=(String )newItem.getAttributeValue("icon"); 227 if (itemName == null) { 230 itemName = getCveRoot() + "/resource/cve/CVE.gif"; 231 }else { 232 itemName = getCveRoot() + itemName; 233 } 234 app.add(itemName); 235 } 236 } 237 } 238 cont++; 239 } 240 } 241 return app; 242 } 243 244 247 static private Element ConfigurationRead() { 248 Cve.errLog.debug(""); 249 File fileConfig=new File("conf/cveConfiguration.xml"); 250 Document docConfig=null; 251 try { 252 SAXBuilder builder = new SAXBuilder(false); 254 docConfig = builder.build(fileConfig); 255 } catch (JDOMException e) { 256 Cve.errLog.error(e.toString()); 257 } 258 Element rootXml=docConfig.getRootElement(); 259 return rootXml; 260 } 261 262 } | Popular Tags |