1 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 19 abstract public class PageConfig { 20 private String pageName_ ; 21 private String description_ ; 22 private PageDecorator decorator_ ; 23 private List exceptionHandlers_ = new ArrayList(5); 24 private List permissionVerifiers_ = new ArrayList(5); 25 26 public String getPageName() { return pageName_ ; } 27 public PageConfig setPageName(String pageName) { 28 pageName_ = pageName ; 29 return this ; 30 } 31 32 public String getDescription() { return description_ ; } 33 public PageConfig setDescription(String 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 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 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 { 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 { 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 ; 87 } | Popular Tags |