1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; 19 import org.apache.cocoon.components.treeprocessor.InvokeContext; 20 import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; 21 import org.apache.cocoon.environment.Environment; 22 import org.apache.cocoon.environment.Redirector; 23 import org.apache.cocoon.environment.PermanentRedirector; 24 import org.apache.cocoon.sitemap.PatternException; 25 26 31 32 public class RedirectToURINode extends AbstractProcessingNode { 33 34 37 38 private VariableResolver uri; 39 40 private boolean createSession; 41 42 private boolean global; 43 44 private boolean permanent; 45 46 public RedirectToURINode(VariableResolver uri, boolean createSession, boolean global, boolean permanent ) 47 throws PatternException { 48 this.global = global; 49 this.uri = uri; 50 this.createSession = createSession; 51 this.permanent = permanent; 52 } 53 54 public final boolean invoke(Environment env, InvokeContext context) 55 throws Exception { 56 String resolvedURI = uri.resolve(context, env.getObjectModel()); 57 58 if (getLogger().isInfoEnabled()) { 59 getLogger().info("Redirecting to '" + resolvedURI + "' at " + this.getLocation()); 60 } 61 62 final Redirector redirector = context.getRedirector(); 63 64 if( this.global ) { 65 redirector.globalRedirect(this.createSession, resolvedURI); 66 } else if (this.permanent && redirector instanceof PermanentRedirector) { 67 ((PermanentRedirector)redirector).permanentRedirect(this.createSession, resolvedURI); 68 } else { 69 redirector.redirect(this.createSession, resolvedURI); 70 } 71 72 return true; 73 } 74 } 75 | Popular Tags |