View Javadoc

1   /**
2    * 2007, Digitalis Informatica. All rights reserved. Distribuicao e Gestao de Informatica, Lda. Estrada de Paco de Arcos
3    * num.9 - Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21 4408999 http://www.digitalis.pt
4    */
5   package pt.digitalis.dif.controller.http;
6   
7   import pt.digitalis.dif.ioc.DIFIoCRegistry;
8   import pt.digitalis.utils.config.IConfigurations;
9   import pt.digitalis.utils.config.annotations.ConfigDefault;
10  import pt.digitalis.utils.config.annotations.ConfigID;
11  import pt.digitalis.utils.config.annotations.ConfigIgnore;
12  import pt.digitalis.utils.config.annotations.ConfigSectionID;
13  
14  /**
15   * Configuration point for the HTTP Controller.
16   * 
17   * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a>
18   * @created Dec 23, 2007
19   */
20  @ConfigID("dif2")
21  @ConfigSectionID("Controller/HTTP")
22  public class HTTPControllerConfiguration {
23  
24      /** The singleton instance property */
25      private static HTTPControllerConfiguration instance;
26  
27      /**
28       * Returns the active configuration object instance.
29       * 
30       * @return the configuration instance
31       */
32      @ConfigIgnore
33      static public HTTPControllerConfiguration getInstance()
34      {
35          if (instance == null)
36              try
37              {
38                  instance = DIFIoCRegistry.getRegistry().getImplementation(IConfigurations.class)
39                          .readConfiguration(HTTPControllerConfiguration.class);
40              }
41              catch (Exception e)
42              {
43                  instance = null;
44              }
45  
46          return instance;
47      }
48  
49      /** The error page for an inexistent stage */
50      private String badStageStageID;
51  
52      /** Determines if cas is active or not */
53      private Boolean centralAuthencication;
54  
55      /** The id of the default change password page */
56      private String changePasswordID;
57  
58      /** The id of the stage do display on errors */
59      private String dynamicErrorStageID;
60  
61      /** The id of the default home page */
62      private String homeStageID;
63  
64      /** The path to the chart listener within the application */
65      private String listenerChartName;
66  
67      /** The path to the document listener within the application */
68      private String listenerDocName;
69  
70      /** The path to the listener within the application */
71      private String listenerName;
72  
73      /** The id of the default login page */
74      private String loginStageID;
75  
76      /** The id of the default logout page */
77      // TODO: This will no longer be necessary since the logout will be managed by the dispatcher
78      private String logoutStageID;
79  
80      /** The id of the default recovery password page */
81      private String recoveryPasswordID;
82  
83      /** The id of the default recovery password url (will override the recoveryPasswordID) */
84      private String recoveryPasswordURL;
85  
86      /** It defines if the registration stage is active or not */
87      private Boolean registrationActive;
88  
89      /** The default Registration Stage id */
90      private String registrationStageID;
91  
92      /** The URL to redirect for user registration (will override the registrationStageID) */
93      private String registrationURL;
94  
95      /** The id of the default search page */
96      private String searchStageID;
97  
98      /** Override server name discovery for cluster or virtual host environments */
99      private String serverBaseURL;
100 
101     /** If T will allow language changes */
102     private Boolean showChangeLanguage;
103 
104     /** If T will allow UI mode changes */
105     private Boolean showChangeUIMode;
106 
107     /** If T will make the site map available in the default template */
108     private Boolean showSiteMap;
109 
110     /** The id of the default site map page */
111     private String siteMapStageID;
112 
113     /** The path of the page (JSP/HTML) to display when all else fails on DIF */
114     private String staticErrorPage;
115 
116     /** Uses the asset listener for compressing and caching the asset files. Otherwise, will render real the file path */
117     private boolean useAssetListener;
118 
119     /**
120      * Inspector for the 'badStageStageID' attribute.
121      * 
122      * @return the badStageStageID value
123      */
124     @ConfigDefault("errorstagebadstageid")
125     public String getBadStageStageID()
126     {
127         return badStageStageID;
128     }
129 
130     /**
131      * Inspector for the 'centralAuthencication' attribute.
132      * 
133      * @return the centralAuthencication value
134      */
135     @ConfigDefault("false")
136     public Boolean getCentralAuthencication()
137     {
138         return centralAuthencication;
139     }
140 
141     /**
142      * @return the changePasswordID
143      */
144     @ConfigDefault("changepasswordstage")
145     public String getChangePasswordID()
146     {
147         return changePasswordID;
148     }
149 
150     /**
151      * Inspector for the dynamic error stage id property.
152      * 
153      * @return the dynamicErrorStageID value
154      */
155     @ConfigDefault("errorstage")
156     public String getDynamicErrorStageID()
157     {
158         return this.dynamicErrorStageID;
159     }
160 
161     /**
162      * Inspector for the home stage id property.
163      * 
164      * @return the homeStageID value
165      */
166     @ConfigDefault("difhomestage")
167     public String getHomeStageID()
168     {
169         return this.homeStageID;
170     }
171 
172     /**
173      * @return the listenerChartName
174      */
175     @ConfigDefault("chart")
176     public String getListenerChartName()
177     {
178         return listenerChartName;
179     }
180 
181     /**
182      * @return the listenerDocName
183      */
184     @ConfigDefault("doc")
185     public String getListenerDocName()
186     {
187         return listenerDocName;
188     }
189 
190     /**
191      * Inspector for the listener name property.
192      * 
193      * @return the listenerName value
194      */
195     @ConfigDefault("page")
196     public String getListenerName()
197     {
198         return this.listenerName;
199     }
200 
201     /**
202      * Inspector for the login stage id property.
203      * 
204      * @return the loginStageID value
205      */
206     @ConfigDefault("loginstage")
207     public String getLoginStageID()
208     {
209         return this.loginStageID;
210     }
211 
212     /**
213      * Inspector for the login stage id property.
214      * 
215      * @return the logoutStageID value
216      */
217     @ConfigDefault("logoutstage")
218     public String getLogoutStageID()
219     {
220         return this.logoutStageID;
221     }
222 
223     /**
224      * Inspector for the recovery password stage id property.
225      * 
226      * @return the recoveryPasswordID value
227      */
228     @ConfigDefault("passwordrecoverystage")
229     public String getRecoveryPasswordID()
230     {
231         return recoveryPasswordID;
232     }
233 
234     /**
235      * Inspector for the 'recoveryPasswordURL' attribute.
236      * 
237      * @return the recoveryPasswordURL value
238      */
239     public String getRecoveryPasswordURL()
240     {
241         return recoveryPasswordURL;
242     }
243 
244     /**
245      * Inspector for the 'registrationActive' attribute.
246      * 
247      * @return the registrationActive
248      */
249     @ConfigDefault("true")
250     public Boolean getRegistrationActive()
251     {
252         return registrationActive;
253     }
254 
255     /**
256      * Inspector for the 'registrationStageID' attribute.
257      * 
258      * @return the searchStageID value
259      */
260     @ConfigDefault("RegistrationDisclaimer")
261     public String getRegistrationStageID()
262     {
263         return registrationStageID;
264     }
265 
266     /**
267      * Inspector for the 'registrationURL' attribute.
268      * 
269      * @return the registragionURL value
270      */
271     public String getRegistrationURL()
272     {
273         return registrationURL;
274     }
275 
276     /**
277      * Inspector for the 'searchStageID' attribute.
278      * 
279      * @return the searchStageID value
280      */
281     @ConfigDefault("searchstage")
282     public String getSearchStageID()
283     {
284         return searchStageID;
285     }
286 
287     /**
288      * Inspector for the 'serverBaseURL' attribute.
289      * 
290      * @return the serverBaseURL value
291      */
292     public String getServerBaseURL()
293     {
294         if (serverBaseURL != null && !"".equals(serverBaseURL))
295             return serverBaseURL.replaceAll("\\\\", "/");
296         else
297             return serverBaseURL;
298     }
299 
300     /**
301      * Inspector for the 'showChangeLanguage' attribute.
302      * 
303      * @return the showChangeLanguage value
304      */
305     @ConfigDefault("true")
306     public Boolean getShowChangeLanguage()
307     {
308         return showChangeLanguage;
309     }
310 
311     /**
312      * Inspector for the 'showChangeUIMode' attribute.
313      * 
314      * @return the showChangeUIMode value
315      */
316     @ConfigDefault("true")
317     public Boolean getShowChangeUIMode()
318     {
319         return showChangeUIMode;
320     }
321 
322     /**
323      * Inspector for the 'showSiteMap' attribute.
324      * 
325      * @return the showSiteMap value
326      */
327     @ConfigDefault("false")
328     public Boolean getShowSiteMap()
329     {
330         return showSiteMap;
331     }
332 
333     /**
334      * Inspector for the 'siteMapStageID' attribute.
335      * 
336      * @return the siteMapStageID value
337      */
338     @ConfigDefault("sitemap")
339     public String getSiteMapStageID()
340     {
341         return siteMapStageID;
342     }
343 
344     /**
345      * Inspector for the static error page property.
346      * 
347      * @return the staticErrorPage value
348      */
349     @ConfigDefault("internal/staticErrorPage.jsp")
350     public String getStaticErrorPage()
351     {
352         return this.staticErrorPage;
353     }
354 
355     /**
356      * Inspector for the 'useAssetListener' attribute.
357      * 
358      * @return the useAssetListener value
359      */
360     @ConfigDefault("true")
361     public boolean getUseAssetListener()
362     {
363         return useAssetListener;
364     }
365 
366     /**
367      * Modifier for the 'badStageStageID' attribute.
368      * 
369      * @param badStageStageID
370      *            the new badStageStageID value to set
371      */
372     public void setBadStageStageID(String badStageStageID)
373     {
374         this.badStageStageID = badStageStageID;
375     }
376 
377     /**
378      * Modifier for the 'centralAuthencication' attribute.
379      * 
380      * @param centralAuthencication
381      *            the new centralAuthencication value to set
382      */
383     public void setCentralAuthencication(Boolean centralAuthencication)
384     {
385         this.centralAuthencication = centralAuthencication;
386     }
387 
388     /**
389      * @param changePasswordID
390      *            the changePasswordID to set
391      */
392     public void setChangePasswordID(String changePasswordID)
393     {
394         this.changePasswordID = changePasswordID;
395     }
396 
397     /**
398      * Modifier for the dynamic error stage id property.
399      * 
400      * @param dynamicErrorStageID
401      *            the dynamicErrorStageID to set
402      */
403     public void setDynamicErrorStageID(String dynamicErrorStageID)
404     {
405         this.dynamicErrorStageID = dynamicErrorStageID;
406     }
407 
408     /**
409      * Modifier for the home stage id property.
410      * 
411      * @param homeStageID
412      *            the homeStageID to set
413      */
414     public void setHomeStageID(String homeStageID)
415     {
416         this.homeStageID = homeStageID;
417     }
418 
419     /**
420      * @param listenerChartName
421      *            the listenerChartName to set
422      */
423     public void setListenerChartName(String listenerChartName)
424     {
425         this.listenerChartName = listenerChartName;
426     }
427 
428     /**
429      * @param listenerDocName
430      *            the listenerDocName to set
431      */
432     public void setListenerDocName(String listenerDocName)
433     {
434         this.listenerDocName = listenerDocName;
435     }
436 
437     /**
438      * Modifier for the listener name property.
439      * 
440      * @param listenerName
441      *            the listenerName to set
442      */
443     public void setListenerName(String listenerName)
444     {
445         this.listenerName = listenerName;
446     }
447 
448     /**
449      * Modifier for the login stage id property.
450      * 
451      * @param loginStageID
452      *            the loginStageID to set
453      */
454     public void setLoginStageID(String loginStageID)
455     {
456         this.loginStageID = loginStageID;
457     }
458 
459     /**
460      * Modifier for the logout stage id property.
461      * 
462      * @param logoutStageID
463      *            the logoutStageID to set
464      */
465     public void setLogoutStageID(String logoutStageID)
466     {
467         this.logoutStageID = logoutStageID;
468     }
469 
470     /**
471      * Modifier for the recoveryPasswordID property
472      * 
473      * @param recoveryPasswordID
474      *            the registrationActive to set
475      */
476     public void setRecoveryPasswordID(String recoveryPasswordID)
477     {
478         this.recoveryPasswordID = recoveryPasswordID;
479     }
480 
481     /**
482      * Modifier for the 'recoveryPasswordURL' attribute.
483      * 
484      * @param recoveryPasswordURL
485      *            the new recoveryPasswordURL value to set
486      */
487     public void setRecoveryPasswordURL(String recoveryPasswordURL)
488     {
489         this.recoveryPasswordURL = recoveryPasswordURL;
490     }
491 
492     /**
493      * Modifier for the registrationActive property
494      * 
495      * @param registrationActive
496      *            the registrationActive to set
497      */
498     public void setRegistrationActive(Boolean registrationActive)
499     {
500         this.registrationActive = registrationActive;
501     }
502 
503     /**
504      * Modifier for the Registration page id
505      * 
506      * @param registrationStageID
507      *            the registrationStageID to set
508      */
509     public void setRegistrationStageID(String registrationStageID)
510     {
511         this.registrationStageID = registrationStageID;
512     }
513 
514     /**
515      * Modifier for the 'registrationURL' attribute.
516      * 
517      * @param registrationURL
518      *            the new registrationURL value to set
519      */
520     public void setRegistrationURL(String registrationURL)
521     {
522         this.registrationURL = registrationURL;
523     }
524 
525     /**
526      * Modifier for the 'searchStageID' attribute.
527      * 
528      * @param searchStageID
529      *            the new searchStageID value to set
530      */
531     public void setSearchStageID(String searchStageID)
532     {
533         this.searchStageID = searchStageID;
534     }
535 
536     /**
537      * Modifier for the 'serverBaseURL' attribute.
538      * 
539      * @param serverBaseURL
540      *            the new serverBaseURL value to set
541      */
542     public void setServerBaseURL(String serverBaseURL)
543     {
544         this.serverBaseURL = serverBaseURL;
545     }
546 
547     /**
548      * Modifier for the 'showChangeLanguage' attribute.
549      * 
550      * @param showChangeLanguage
551      *            the new showChangeLanguage value to set
552      */
553     public void setShowChangeLanguage(Boolean showChangeLanguage)
554     {
555         this.showChangeLanguage = showChangeLanguage;
556     }
557 
558     /**
559      * Modifier for the 'showChangeUIMode' attribute.
560      * 
561      * @param showChangeUIMode
562      *            the new showChangeUIMode value to set
563      */
564     public void setShowChangeUIMode(Boolean showChangeUIMode)
565     {
566         this.showChangeUIMode = showChangeUIMode;
567     }
568 
569     /**
570      * Modifier for the 'showSiteMap' attribute.
571      * 
572      * @param showSiteMap
573      *            the new showSiteMap value to set
574      */
575     public void setShowSiteMap(Boolean showSiteMap)
576     {
577         this.showSiteMap = showSiteMap;
578     }
579 
580     /**
581      * Modifier for the 'siteMapStageID' attribute.
582      * 
583      * @param siteMapStageID
584      *            the new siteMapStageID value to set
585      */
586     public void setSiteMapStageID(String siteMapStageID)
587     {
588         this.siteMapStageID = siteMapStageID;
589     }
590 
591     /**
592      * Modifier for the static error page property.
593      * 
594      * @param staticErrorPage
595      *            the staticErrorPage to set
596      */
597     public void setStaticErrorPage(String staticErrorPage)
598     {
599         this.staticErrorPage = staticErrorPage;
600     }
601 
602     /**
603      * Modifier for the 'useAssetListener' attribute.
604      * 
605      * @param useAssetListener
606      *            the new useAssetListener value to set
607      */
608     public void setUseAssetListener(boolean useAssetListener)
609     {
610         this.useAssetListener = useAssetListener;
611     }
612 }