this.hasRedirected = true;
}
private void cocoonRedirect(boolean sessionMode, String uri)
throws IOException, ProcessingException {
Processor actualProcessor = null;
try {
boolean rawMode = false;
String prefix;
// remove the protocol
int protocolEnd = uri.indexOf(':');
if (protocolEnd != -1) {
uri = uri.substring(protocolEnd + 1);
// check for subprotocol
if (uri.startsWith("raw:")) {
uri = uri.substring(4);
rawMode = true;
}
}
Processor usedProcessor;
// Does the uri point to this sitemap or to the root sitemap?
if (uri.startsWith("//")) {
uri = uri.substring(2);
prefix = ""; // start at the root
try {
actualProcessor = (Processor)this.manager.lookup(Processor.ROLE);
usedProcessor = actualProcessor;
} catch (ComponentException e) {
throw new ProcessingException("Cannot get Processor instance", e);
}
} else if (uri.startsWith("/")) {
prefix = null; // means use current prefix
uri = uri.substring(1);
usedProcessor = this.processor;
} else {
throw new ProcessingException("Malformed cocoon URI.");
}
// create the queryString (if available)
String queryString = null;
int queryStringPos = uri.indexOf('?');
if (queryStringPos != -1) {
queryString = uri.substring(queryStringPos + 1);
uri = uri.substring(0, queryStringPos);
}
// build the request uri which is relative to the context
String requestURI = (prefix == null ? env.getURIPrefix() + uri : uri);
ForwardEnvironmentWrapper newEnv =
new ForwardEnvironmentWrapper(env, requestURI, queryString, getLogger(), rawMode);
newEnv.setURI(prefix, uri);
boolean processingResult;
// FIXME - What to do here?
Object processKey = CocoonComponentManager.startProcessing(newEnv);
try {
if ( !this.internal ) {
processingResult = usedProcessor.process(newEnv);
} else {
ProcessingPipeline pp = usedProcessor.buildPipeline(newEnv);
if (pp != null) pp.release();
processingResult = pp != null;
}
} finally {
CocoonComponentManager.endProcessing(newEnv, processKey);