1 16 package org.apache.jetspeed.modules.actions; 17 18 import org.apache.turbine.TurbineConstants; 20 import org.apache.turbine.util.RunData; 21 import org.apache.turbine.modules.actions.sessionvalidator.SessionValidator; 22 import org.apache.jetspeed.services.rundata.JetspeedRunData; 23 import org.apache.jetspeed.services.resources.JetspeedResources; 24 import org.apache.jetspeed.services.JetspeedSecurity; 25 26 40 public class TemplateSessionValidator extends SessionValidator 41 { 42 48 public void doPerform( RunData rundata ) throws Exception 49 { 50 JetspeedRunData data = (JetspeedRunData)rundata; 51 54 data.populate(); 55 56 if ( data.getUser() == null) 58 { 59 data.setUser(JetspeedSecurity.getAnonymousUser()); 60 data.save(); 61 } 62 63 if ( !data.hasScreen() && 65 data.getTemplateInfo().getScreenTemplate() == null ) 66 { 67 String template = JetspeedResources.getString( 68 TurbineConstants.TEMPLATE_HOMEPAGE); 69 70 if (template != null) 71 { 72 data.getTemplateInfo().setScreenTemplate(template); 73 } 74 else 75 { 76 data.setScreen(JetspeedResources.getString( 77 TurbineConstants.SCREEN_HOMEPAGE)); 78 } 79 } 80 else if ( data.getParameters().containsKey("_session_access_counter") ) 84 { 85 if ( data.getParameters().getInt("_session_access_counter") < 87 (((Integer )data.getUser().getTemp("_session_access_counter")) 88 .intValue()-1) ) 89 { 90 if (data.getTemplateInfo().getScreenTemplate() != null) 91 { 92 data.getUser().setTemp( "prev_template", 93 data.getTemplateInfo().getScreenTemplate() 94 .replace('/', ',') ); 95 data.getTemplateInfo().setScreenTemplate( 96 JetspeedResources.getString( 97 TurbineConstants.TEMPLATE_INVALID_STATE) ); 98 } 99 else 100 { 101 data.getUser().setTemp( "prev_screen", 102 data.getScreen().replace('/', ',') ); 103 data.setScreen( JetspeedResources.getString( 104 TurbineConstants.SCREEN_INVALID_STATE) ); 105 } 106 data.getUser().setTemp("prev_parameters", data.getParameters()); 107 data.setAction( "" ); 108 } 109 } 110 111 if ( data.getTemplateInfo().getScreenTemplate() != null ) 114 { 115 data.setScreen(null); 116 } 117 } 118 119 128 public boolean requiresNewSession(RunData data) 129 { 130 return true; 131 } 132 } 133 134 | Popular Tags |