1 20 21 package com.methodhead.shim; 22 23 import java.io.Serializable ; 24 import javax.servlet.http.HttpServletRequest ; 25 26 import org.apache.struts.action.ActionMapping; 27 import org.apache.struts.action.ActionErrors; 28 import org.apache.struts.action.ActionError; 29 import org.apache.struts.validator.DynaValidatorForm; 30 import java.util.List ; 31 import java.util.ArrayList ; 32 import java.util.Iterator ; 33 import org.apache.struts.util.LabelValueBean; 34 import com.methodhead.sitecontext.SiteContext; 35 import com.methodhead.auth.AuthUtil; 36 import com.methodhead.tree.Tree; 37 import org.apache.commons.lang.StringUtils; 38 import java.io.File ; 39 40 public final class NavModuleForm 41 extends 42 DynaValidatorForm 43 implements 44 Serializable { 45 46 49 private ShimPolicy getPolicy( 50 ActionMapping mapping ) { 51 52 try { 53 return 54 ( ShimPolicy )Class.forName( mapping.getParameter() ).newInstance(); 55 } 56 catch ( Exception e ) { 57 throw new ShimException( 58 "Unexpected exception while instantiating \"" + 59 mapping.getParameter() +"\":" + e.getMessage() ); 60 } 61 } 62 63 93 94 public ActionErrors validate( 95 ActionMapping mapping, 96 HttpServletRequest request ) { 97 98 if ( !StringUtils.isBlank( ( String )get( "cancel" ) ) ) 102 return new ActionErrors(); 103 104 ActionErrors errors = super.validate( mapping, request ); 105 106 if ( errors.size() == 0 ) { 107 108 if ( "jsp".equals( get( "type" ) ) ) { 109 if ( StringUtils.isBlank( ( String )get( "jsp" ) ) ) { 110 errors.add( "jsp", new ActionError( "shim.navModuleForm.missingJsp" ) ); 111 } 112 else { 113 File file = 117 new File ( request.getSession().getServletContext().getRealPath( 118 "/WEB-INF/resources/" + 119 SiteContext.getContext( request ).getInt( "id" ) + "/" + 120 get( "jsp" ) ) ); 121 122 if ( !file.exists() || !file.isFile() ) 123 errors.add( 124 "jsp", new ActionError( "shim.navModuleForm.invalidJsp" ) ); 125 } 126 } 127 } 128 return errors; 129 } 130 } 131 | Popular Tags |