// Build an environment wrapper
// If the current env is a facade, change the delegate and continue processing the facade, since
// we may have other redirects that will in turn also change the facade delegate
MutableEnvironmentFacade facade = environment instanceof MutableEnvironmentFacade ?
((MutableEnvironmentFacade)environment) : null;
if (facade != null) {
// Consider the facade delegate (the real environment)
environment = facade.getDelegate();
}
// test if this is a call from flow
boolean isRedirect = (environment.getObjectModel().remove("cocoon:forward") == null);
Environment newEnv = new ForwardEnvironmentWrapper(environment, this.sitemapComponentManager, uri, getLogger());
if ( isRedirect ) {
((ForwardEnvironmentWrapper)newEnv).setInternalRedirect(true);
}
if (facade != null) {
// Change the facade delegate
facade.setDelegate((EnvironmentWrapper)newEnv);
newEnv = facade;
}
// Get the processor that should process this request
// (see https://issues.apache.org/jira/browse/COCOON-1990).
ConcreteTreeProcessor processor = this;
if (uri.startsWith("cocoon://"))
processor = ((TreeProcessor)getRootProcessor()).concreteProcessor;
// Process the redirect
// No more reset since with TreeProcessorRedirector, we need to pop values from the redirect location
// context.reset();
// The following is a fix for bug #26854 and #26571
final boolean result = processor.process(newEnv, context);
if ( facade != null ) {
newEnv = facade.getDelegate();
}
if ( ((ForwardEnvironmentWrapper)newEnv).getRedirectURL() != null ) {
environment.redirect( false, ((ForwardEnvironmentWrapper)newEnv).getRedirectURL() );
}
return result;