}
@Override
public void perform(final Rewrite event, final EvaluationContext ec)
{
PrettyContext context = PrettyContext.getCurrentInstance(((HttpServletRewrite) event).getRequest());
if (event instanceof HttpInboundServletRewrite)
{
((HttpServletRewrite) event).getRequest().setAttribute(REWRITE_MAPPING_ID_KEY,
REWRITE_MAPPING_ID_KEY + ":" + mapping.getId());
URL url = context.getRequestURL();
if (context.shouldProcessDynaview())
{
log.trace("Forwarding mapped request [" + url.toURL() + "] to dynaviewId [" + context.getDynaViewId() + "]");
((HttpInboundServletRewrite) event).forward(context.getDynaViewId());
}
else
{
String viewId = mapping.getViewId();
log.trace("Forwarding mapped request [" + url.toURL() + "] to resource [" + viewId + "]");
if (url.decode().toURL().equals(viewId))
{
((HttpServletRewrite) event).proceed();
}
else
{
((HttpInboundServletRewrite) event).forward(viewId);
}
}
}
else if ((event instanceof HttpOutboundServletRewrite) && mapping.isOutbound())
{
HttpOutboundServletRewrite outboundRewrite = (HttpOutboundServletRewrite) event;
String newUrl = rewritePrettyMappings(context.getConfig(), ((HttpServletRewrite) event).getContextPath(),
outboundRewrite.getOutboundAddress().toString());
outboundRewrite.setOutboundAddress(AddressBuilder.create(newUrl));
}
}