1 20 21 package com.methodhead.shim; 22 23 import org.apache.struts.action.Action; 24 import org.apache.struts.action.ActionMapping; 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.DynaActionForm; 27 import org.apache.struts.action.ActionForward; 28 29 import com.methodhead.auth.AuthAction; 30 31 import javax.servlet.RequestDispatcher ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 import com.methodhead.auth.AuthUser; 35 import com.methodhead.auth.AuthUtil; 36 import com.methodhead.sitecontext.SiteContext; 37 import com.methodhead.util.OperationContext; 38 import com.methodhead.util.StrutsUtil; 39 import com.methodhead.persistable.PersistableException; 40 import java.util.Iterator ; 41 import com.methodhead.aikp.IntKey; 42 43 public class ViewPageAction 44 extends 45 Action { 46 47 49 51 53 55 58 protected ActionForward doEmptySite( 59 OperationContext op, 60 ShimPolicy policy ) 61 throws 62 Exception { 63 64 return op.mapping.findForward( "form" ); 65 } 66 67 70 protected ActionForward doPageNotFound( 71 OperationContext op, 72 ShimPolicy policy ) 73 throws 74 Exception { 75 76 return op.mapping.findForward( "form" ); 77 } 78 79 public ActionForward execute( 80 ActionMapping mapping, 81 ActionForm form, 82 HttpServletRequest request, 83 HttpServletResponse response ) 84 throws 85 Exception { 86 87 DynaActionForm dynaForm = ( DynaActionForm )form; 91 ShimPolicy policy = ( ShimPolicy )StrutsUtil.getPolicy( mapping ); 92 AuthUser user = AuthUtil.getUser( request ); 93 94 if ( !policy.isMappingAuthorized( user, mapping.getPath() ) ) 98 return mapping.findForward( "accessDenied" ); 99 100 OperationContext op = 101 new OperationContext( mapping, dynaForm, request, response, user ); 102 103 if ( mapping.getPath().equals( "/emptySite" ) ) { 107 return doEmptySite( op, policy ); 108 } 109 if ( mapping.getPath().equals( "/pageNotFound" ) ) { 110 return doPageNotFound( op, policy ); 111 } 112 113 throw 114 new Exception ( "Unexpected mapping path \"" + mapping.getPath() + "\"" ); 115 } 116 117 119 } 121 | Popular Tags |