Example usage for org.apache.wicket.request Url removeQueryParameters

List of usage examples for org.apache.wicket.request Url removeQueryParameters

Introduction

In this page you can find the example usage for org.apache.wicket.request Url removeQueryParameters.

Prototype

public void removeQueryParameters(final String name) 

Source Link

Document

Convenience method that removes all query parameters with given name.

Usage

From source file:org.jabylon.rest.ui.wicket.CustomExceptionMapper.java

License:Open Source License

@Override
public IRequestHandler map(Exception e) {
    if (e instanceof ObjectNotFoundException) {
        //see https://github.com/jutzig/jabylon/issues/175
        Request request = RequestCycle.get().getRequest();
        Url url = request.getUrl();
        List<QueryParameter> parameters = url.getQueryParameters();
        boolean redirected = false;
        for (QueryParameter queryParameter : parameters) {
            if (queryParameter.getValue().isEmpty() && queryParameter.getName().matches("\\d+")) {
                url.removeQueryParameters(queryParameter.getName());
                LOG.error("Detected request to expired CDO ID. Attempting redirect to " + url.toString(), e);
                Session.get().error("Sorry, this page content has expired. Please try again");
                redirected = true;/*from w w w .  ja  v a  2s . c  om*/
                break;
            }
        }
        if (redirected)
            return new RedirectRequestHandler("/" + url.toString());
    }
    return super.map(e);
}