1 5 6 package com.raptus.owxv3; 7 8 import java.text.ParseException ; 9 import java.util.*; 10 11 33 public class VModuleSectionElement extends Object 34 { 35 38 protected String identification = null; 39 40 43 protected VModuleSection vmsection = null; 44 45 48 protected Hashtable displayNames = null; 49 50 53 protected String uri = null; 54 55 58 protected String controller = null; 59 60 63 64 65 protected String view = null; 66 67 68 71 protected Hashtable forwards=null; 72 73 74 77 protected String [] locales=null; 78 79 82 protected String roles[] = null; 83 84 89 public String [] getRoles() 90 { 91 return roles; 92 } 93 94 97 public boolean initialize(String element, VModuleSection section) 98 { 99 this.identification = element; 100 this.vmsection = section; 101 102 VModule vm = vmsection.getVModule(); 103 locales=vm.getLocales(); 104 XMLConfigManager cm = XMLConfigManager.getInstance(); 105 106 Configuration cfg = cm.getConfiguration(); 107 String pfx = Constants.VMODULE_PREFIX + vm.getIdentification() + Constants.VMODULE_SECTION_PREFIX + 108 vmsection.getIdentification() + Constants.VMODULE_SECTION_ELEMENT_PREFIX + 109 identification; 110 111 112 roles = cm.getStringArrayByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/roles", "value"); 113 if(roles != null) 114 { 115 for(int i=0;i<roles.length;i++) 116 { 117 LoggingManager.log("Role for element "+element+":"+roles[i], this); 118 } 119 } 120 else 121 { 122 LoggingManager.log("No roles for element "+element, this); 123 } 124 125 uri=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/property?name=uri", "value"); 127 controller=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/property?name=controller", "value"); 130 view=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/property?name=view", "value"); 134 forwards=new Hashtable(); 136 137 String fwrds[]=cm.getStringArrayByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element, "forwards"); 139 145 String forwarduri=null; 146 if(fwrds!=null) 147 { 148 for(int i=0;i<fwrds.length;i++) 149 { 150 forwarduri=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/forward?name="+fwrds[i], "uri"); 152 if(forwarduri!=null) 154 { 155 forwards.put(vm.getIdentification() + Constants.DEFAULT_SPACER + vmsection.getIdentification() +Constants.DEFAULT_SPACER + fwrds[i],forwarduri); 156 } } } 160 displayNames = new Hashtable(); 163 String [] locales = vm.getLocales(); 164 for(int i = 0; i < locales.length; i ++) 165 { 166 String displayname=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/property?name=displayname/label?locale="+locales[i],"value"); 168 if(displayname != null) 169 displayNames.put(locales[i], displayname); 170 } 172 173 return true; 174 } 175 176 179 public String getStringProperty(String property) 180 { 181 VModule vm = vmsection.getVModule(); 182 Configuration cfg = vm.getConfiguration(); 183 return cfg.getStringByKey(Constants.VMODULE_PREFIX + vm.getIdentification() + 184 Constants.VMODULE_SECTION_PREFIX + vmsection.getIdentification() + 185 Constants.VMODULE_SECTION_ELEMENT_PREFIX + identification + 186 Constants.VMODULE_SECTION_ELEMENT_PROPERTY_PREFIX + property); 187 } 188 189 192 public boolean getBooleanProperty(String property) 193 throws ParseException 194 { 195 VModule vm = vmsection.getVModule(); 196 Configuration cfg = vm.getConfiguration(); 197 return cfg.getBooleanByKey(Constants.VMODULE_PREFIX + vm.getIdentification() + 198 Constants.VMODULE_SECTION_PREFIX + vmsection.getIdentification() + 199 Constants.VMODULE_SECTION_ELEMENT_PREFIX + identification + 200 Constants.VMODULE_SECTION_ELEMENT_PROPERTY_PREFIX + property); 201 } 202 203 206 public int getIntegerProperty(String property) 207 throws ParseException 208 { 209 VModule vm = vmsection.getVModule(); 210 Configuration cfg = vm.getConfiguration(); 211 return cfg.getIntByKey(Constants.VMODULE_PREFIX + vm.getIdentification() + 212 Constants.VMODULE_SECTION_PREFIX + vmsection.getIdentification() + 213 Constants.VMODULE_SECTION_ELEMENT_PREFIX + identification + 214 Constants.VMODULE_SECTION_ELEMENT_PROPERTY_PREFIX + property); 215 } 216 217 220 public String getViewName() 221 { 222 VModule vm = vmsection.getVModule(); 223 return vm.getIdentification() + Constants.DEFAULT_SPACER + vmsection.getIdentification() + 224 Constants.DEFAULT_SPACER + identification; 225 } 226 227 230 public String getIdentification() { return identification; } 231 232 235 public VModuleSection getSection() { return vmsection; } 236 237 240 public String getDisplayname(String locale) 241 { 242 String l=null; 243 l=(String )displayNames.get(locale); 244 if(l==null || "".equals(l)) 245 { 246 for(int i=0;i<locales.length;i++) 247 { 248 l=(String )displayNames.get(locales[i]); 249 if(l!=null && ! "".equals(l)) break; 250 251 } } 254 return l; 255 } 256 257 260 public String getDisplayname(Locale locale) { return getDisplayname(locale.toString()); } 261 262 265 public String getURI() { return uri; } 266 267 270 public String getController() { return controller; } 271 272 275 276 277 public String getView() { return view; } 278 279 280 283 284 public Hashtable getForwards() { return forwards; } 285 } 286 287 288 | Popular Tags |