KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > VModuleSectionElement


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3;
7
8 import java.text.ParseException JavaDoc;
9 import java.util.*;
10
11 /**
12  *
13  * <hr>
14  * <table width="100%" border="0">
15  * <tr>
16  * <td width="24%"><b>Filename</b></td><td width="76%">VModuleSectionElement.java</td>
17  * </tr>
18  * <tr>
19  * <td width="24%"><b>Author</b></td><td width="76%">Guy Z�rcher (gzuercher@raptus.com)</td>
20  * </tr>
21  * <tr>
22  * <td width="24%"><b>Date</b></td><td width="76%">26th of April 2001</td>
23  * </tr>
24  * </table>
25  * <hr>
26  * <table width="100%" border="0">
27  * <tr>
28  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
29  * </tr>
30  * </table>
31  * <hr>
32  */

33 public class VModuleSectionElement extends Object JavaDoc
34 {
35     /**
36      *
37      */

38     protected String JavaDoc identification = null;
39
40     /**
41      *
42      */

43     protected VModuleSection vmsection = null;
44
45     /**
46      *
47      */

48     protected Hashtable displayNames = null;
49
50     /**
51      *
52      */

53     protected String JavaDoc uri = null;
54
55     /**
56      *
57      */

58     protected String JavaDoc controller = null;
59
60     /**
61      *
62      */

63
64
65     protected String JavaDoc view = null;
66
67
68     /**
69      *
70      */

71     protected Hashtable forwards=null;
72
73
74     /**
75      *
76      */

77     protected String JavaDoc[] locales=null;
78
79     /**
80      * The roles available for this element
81      */

82     protected String JavaDoc roles[] = null;
83     
84     /**
85      * Return the roles available for this element
86      *
87      * @return the roles available for this element
88      */

89     public String JavaDoc[] getRoles()
90     {
91         return roles;
92     }
93     
94     /**
95      *
96      */

97     public boolean initialize(String JavaDoc 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 JavaDoc 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 = cfg.getStringByKey(pfx + Constants.VMODULE_SECTION_ELEMENT_URI);
126
uri=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/property?name=uri", "value");
127 // LoggingManager.log("URI="+uri, this);
128
//controller = cfg.getStringByKey(pfx + Constants.VMODULE_SECTION_ELEMENT_CONTROLLER);
129
controller=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/property?name=controller", "value");
130 // LoggingManager.log("Controller="+controller, this);
131
//view = cfg.getStringByKey(pfx + Constants.VMODULE_SECTION_ELEMENT_VIEW);
132
//view = cfg.getStringByKey(pfx + Constants.VMODULE_SECTION_ELEMENT_VIEW);
133
view=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/property?name=view", "value");
134 // LoggingManager.log("view="+view, this);
135
forwards=new Hashtable();
136
137         //String fwrds[]=cfg.getStringArrayByKey(pfx+Constants.VMODULE_SECTION_ELEMENT_FORWARDS);
138
String JavaDoc fwrds[]=cm.getStringArrayByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element, "forwards");
139 // LoggingManager.log("Forwards="+fwrds, this);
140
// if(fwrds!=null)
141
// {
142
// LoggingManager.log("Got "+fwrds.length+" forwards", this);
143
// }
144

145         String JavaDoc forwarduri=null;
146         if(fwrds!=null)
147         {
148             for(int i=0;i<fwrds.length;i++)
149             {
150                 //forwarduri=cfg.getStringByKey(pfx+Constants.VMODULE_SECTION_ELEMENT_FORWARD+fwrds[i]+Constants.VMODULE_SECTION_ELEMENT_URI);
151
forwarduri=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/"+vmsection.getIdentification()+"/element?name="+element+"/forward?name="+fwrds[i], "uri");
152 // LoggingManager.log("Forward uri="+forwarduri, this);
153
if(forwarduri!=null)
154                 {
155                     forwards.put(vm.getIdentification() + Constants.DEFAULT_SPACER + vmsection.getIdentification() +Constants.DEFAULT_SPACER + fwrds[i],forwarduri);
156                 }//end if
157
}//end for
158
}//end if
159

160 // LoggingManager.log("Resolved forwards!",this);
161
// loop through locales
162
displayNames = new Hashtable();
163         String JavaDoc[] locales = vm.getLocales();
164         for(int i = 0; i < locales.length; i ++)
165         {
166             //String displayname = cfg.getStringByKey(pfx + Constants.VMODULE_SECTION_ELEMENT_DISPLAYNAME_PREFIX + locales[i]);
167
String JavaDoc 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 // LoggingManager.log("Display name for locale "+locales[i]+" is "+displayname, this);
171
}
172
173         return true;
174     }
175
176     /**
177      *
178      */

179     public String JavaDoc getStringProperty(String JavaDoc 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     /**
190      *
191      */

192     public boolean getBooleanProperty(String JavaDoc property)
193                    throws ParseException JavaDoc
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     /**
204      *
205      */

206     public int getIntegerProperty(String JavaDoc property)
207                throws ParseException JavaDoc
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     /**
218      *
219      */

220     public String JavaDoc getViewName()
221     {
222         VModule vm = vmsection.getVModule();
223         return vm.getIdentification() + Constants.DEFAULT_SPACER + vmsection.getIdentification() +
224                Constants.DEFAULT_SPACER + identification;
225     }
226
227     /**
228      *
229      */

230     public String JavaDoc getIdentification() { return identification; }
231
232     /**
233      *
234      */

235     public VModuleSection getSection() { return vmsection; }
236
237     /**
238      *
239      */

240     public String JavaDoc getDisplayname(String JavaDoc locale)
241     {
242         String JavaDoc l=null;
243         l=(String JavaDoc)displayNames.get(locale);
244         if(l==null || "".equals(l))
245         {
246             for(int i=0;i<locales.length;i++)
247             {
248                 l=(String JavaDoc)displayNames.get(locales[i]);
249                 if(l!=null && ! "".equals(l)) break;
250
251             }//end for
252
}//end if
253

254         return l;
255     }
256
257     /**
258      *
259      */

260     public String JavaDoc getDisplayname(Locale locale) { return getDisplayname(locale.toString()); }
261
262     /**
263      *
264      */

265     public String JavaDoc getURI() { return uri; }
266
267     /**
268      *
269      */

270     public String JavaDoc getController() { return controller; }
271
272     /**
273      *
274      */

275
276
277     public String JavaDoc getView() { return view; }
278
279
280     /**
281      *
282      */

283
284     public Hashtable getForwards() { return forwards; }
285 }
286
287 /* end class VModuleSectionElement */
288
Popular Tags