KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlet > exomvc > config > PageConfig


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlet.exomvc.config ;
6
7 import java.util.* ;
8 import javax.portlet.* ;
9
10 import org.exoplatform.portlet.exomvc.Page;
11 import org.exoplatform.portlet.exomvc.PageDecorator ;
12 import org.exoplatform.portlet.exomvc.exception.ExceptionHandler;
13 import org.exoplatform.portlet.exomvc.interceptor.Interceptor;
14 /**
15  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
16  * @since Nov 11, 2004
17  * @version $Id$
18  */

19 abstract public class PageConfig {
20   private String JavaDoc pageName_ ;
21   private String JavaDoc description_ ;
22   private PageDecorator decorator_ ;
23   private List exceptionHandlers_ = new ArrayList(5);
24   private List permissionVerifiers_ = new ArrayList(5);
25   
26   public String JavaDoc getPageName() { return pageName_ ; }
27   public PageConfig setPageName(String JavaDoc pageName) {
28     pageName_ = pageName ;
29     return this ;
30   }
31   
32   public String JavaDoc getDescription() { return description_ ; }
33   public PageConfig setDescription(String JavaDoc desc) {
34     description_ = desc ;
35     return this ;
36   }
37   
38   public PageDecorator getPageDecorator() { return decorator_; }
39   public PageConfig setPageDecorator(PageDecorator decorator) {
40     decorator_ = decorator ;
41     return this ;
42   }
43   
44   public PageConfig addExceptionHandler(ExceptionHandler handler) {
45     exceptionHandlers_.add(handler) ;
46     return this ;
47   }
48   
49   public void handle(Throwable JavaDoc t, ActionRequest req, ActionResponse res) {
50     for(int i = 0 ; i < exceptionHandlers_.size(); i++) {
51       ExceptionHandler handler = (ExceptionHandler) exceptionHandlers_.get(i) ;
52       if(handler.canHandle(t)) {
53         handler.handle(this, t, req, res) ;
54       }
55     }
56   }
57   
58   public void handle(Throwable JavaDoc t, RenderRequest req, RenderResponse res) {
59     for(int i = 0 ; i < exceptionHandlers_.size(); i++) {
60       ExceptionHandler handler = (ExceptionHandler) exceptionHandlers_.get(i) ;
61       if(handler.canHandle(t)) {
62         handler.handle(this, t, req, res) ;
63       }
64     }
65   }
66   
67   public PageConfig addPermissionVerifier(Interceptor verifier) {
68     permissionVerifiers_.add(verifier) ;
69     return this ;
70   }
71
72   public void checkPermission(ActionRequest req, ActionResponse res) throws Exception JavaDoc {
73     for(int i = 0; i < permissionVerifiers_.size(); i++) {
74       Interceptor verifier = (Interceptor) permissionVerifiers_.get(i) ;
75       verifier.intercept(this, req, res) ;
76     }
77   }
78   
79   public void checkPermission(RenderRequest req, RenderResponse res) throws Exception JavaDoc {
80     for(int i = 0; i < permissionVerifiers_.size(); i++) {
81       Interceptor verifier = (Interceptor) permissionVerifiers_.get(i) ;
82       verifier.intercept(this, req, res) ;
83     }
84   }
85   
86   abstract public Page getPageObject(Configuration configuration) throws Exception JavaDoc ;
87 }
Popular Tags