else if (event instanceof HttpOutboundServletRewrite)
{
HttpOutboundServletRewrite out = (HttpOutboundServletRewrite) event;
String outboundURL = out.getOutboundAddress().toString();
URLBuilder url = URLBuilder.createFrom(outboundURL);
url.getQueryStringBuilder().removeParameter(tokenName);
QueryStringBuilder newQuery = QueryStringBuilder.createNew();
for (String param : excludedParams) {
newQuery.addParameter(param, url.getQueryStringBuilder().removeParameter(param).toArray(new String[] {}));
}
if (!params.isEmpty())
{
for (String param : url.getQueryStringBuilder().getParameterNames())
{
if (!params.contains(param))
{
newQuery.addParameter(param,
url.getQueryStringBuilder().removeParameter(param).toArray(new String[] {}));
}
}
}
if (outboundURL.contains("?") && (outboundURL.startsWith(out.getContextPath()) || outboundURL.startsWith("/")))
{
if (!url.getQueryStringBuilder().isEmpty())
{
String encoded = checksumStrategy.embedChecksum(url.getQueryStringBuilder().toQueryString());
encoded = encodingStrategy.encode(encoded);
newQuery.addParameter(tokenName, encoded);
out.setOutboundAddress(AddressBuilder.create(url.toPath() + newQuery.toQueryString()));
}
}
}
}