List of usage examples for org.apache.wicket.request Request getUrl
public abstract Url getUrl();
From source file:codetroopers.wicket.web.routes.mapper.ParamCheckingPatternMapper.java
License:Apache License
/** * First delegate to the superclass to parse the request as normal, then additionally * verify that all regular expressions specified in the placeholders match. *///from www. jav a2 s .c o m @Override protected UrlInfo parseRequest(Request request) { // Parse the request normally. If the standard impl can't parse it, we won't either. UrlInfo info = super.parseRequest(request); if (null == info || null == info.getPageParameters()) { return info; } // If exact matching, reject URLs that have more than expected number of segments if (exact) { int requestNumSegments = request.getUrl().getSegments().size(); if (requestNumSegments > this.numSegments) { return null; } } // Loop through each placeholder and verify that the regex of the placeholder matches // the value that was provided in the request url. If any of the values don't match, // immediately return null signifying that the url is not matched by this mapper. PageParameters params = info.getPageParameters(); for (PatternPlaceholder pp : getPatternPlaceholders()) { List<StringValue> values = params.getValues(pp.getName()); if (null == values || values.size() == 0) { values = Arrays.asList(StringValue.valueOf("")); } for (StringValue val : values) { if (!pp.matches(val.toString())) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( String.format("Parameter \"%s\" did not match pattern placeholder %s", val, pp)); } if (ignoreIncorrectParameters) { params.remove(pp.getName(), val.toString()); } else { return null; } } } } return info; }
From source file:com.pushinginertia.wicket.core.util.ComponentUtils.java
License:Open Source License
/** * Constructs a URL by using the same port and scheme/protocol as what was used to request the current page. * @param request object encapsulating the request to the server (used to obtain the container request) * @param absolutePath absolute path to append after the host name (can be null), a leading '/' will be added if * omitted//from w ww .j a va2 s . co m * @return */ public static String constructUrl(final Request request, final String absolutePath) { final String hostName = request.getUrl().getHost(); return constructUrl(request, hostName, absolutePath); }
From source file:fiftyfive.wicket.mapper.PatternMountedMapper.java
License:Apache License
/** * First delegate to the superclass to parse the request as normal, then additionally * verify that all regular expressions specified in the placeholders match. *//* w ww .ja v a 2s. c o m*/ @Override protected UrlInfo parseRequest(Request request) { // Parse the request normally. If the standard impl can't parse it, we won't either. UrlInfo info = super.parseRequest(request); if (null == info || null == info.getPageParameters()) { return info; } // If exact matching, reject URLs that have more than expected number of segments if (exact) { int requestNumSegments = request.getUrl().getSegments().size(); if (requestNumSegments > this.numSegments) { return null; } } // Loop through each placeholder and verify that the regex of the placeholder matches // the value that was provided in the request url. If any of the values don't match, // immediately return null signifying that the url is not matched by this mapper. PageParameters params = info.getPageParameters(); for (PatternPlaceholder pp : getPatternPlaceholders()) { List<StringValue> values = params.getValues(pp.getName()); if (null == values || values.size() == 0) { values = Arrays.asList(StringValue.valueOf("")); } for (StringValue val : values) { if (!pp.matches(val.toString())) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( String.format("Parameter \"%s\" did not match pattern placeholder %s", val, pp)); } return null; } } } return info; }
From source file:fiftyfive.wicket.resource.MergedResourceMapper.java
License:Apache License
public IRequestHandler mapRequest(Request request) { PageParameters parameters = null;/* www . j a v a 2s . c o m*/ List<String> requestSegments = request.getUrl().getSegments(); if (requestSegments.size() < this.mountSegments.length) { return null; } for (int i = 0; i < this.mountSegments.length; i++) { String segment = requestSegments.get(i); if (i + 1 == this.mountSegments.length) { parameters = extractPageParameters(request, this.mountSegments.length, this.parametersEncoder); ResourceUrl resourceUrl = new ResourceUrl(segment, parameters); this.cachingStrategy.get().undecorateUrl(resourceUrl); segment = resourceUrl.getFileName(); } if (!segment.equals(this.mountSegments[i])) { return null; } } return new MergedResourceRequestHandler(this.resources, parameters, getLastModifiedTime(getLastModifiedReference())); }
From source file:jp.xet.uncommons.wicket.fixedurl.FixedUrlHomePageMapper.java
License:Apache License
/** * Matches only when there are no segments/indexed parameters * /* w w w .j a v a 2 s . c om*/ * @see org.apache.wicket.request.mapper.AbstractBookmarkableMapper#parseRequest(org.apache.wicket.request.Request) */ @Override protected UrlInfo parseRequest(Request request) { // get canonical url final Url url = request.getUrl().canonical(); if (url.getSegments().size() > 0) { // home page cannot have segments/indexed parameters return null; } return super.parseRequest(request); }
From source file:name.martingeisse.wicket.application.PermanentRedirectMapper.java
License:Open Source License
@Override public IRequestHandler mapRequest(Request request) { if (request.getUrl().getPath().equals(from)) { return new MyRequestHandler(); } else {//ww w.j av a2 s. co m return null; } }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryRequestCycleListener.java
License:Open Source License
private boolean isSharedResourcesRequest(RequestCycle cycle) { // Use current request, as the private request field can be null Request currentRequest = cycle.getRequest(); String path = currentRequest.getUrl().getPath(); String sharedResourcesPath = ArtifactoryApplication.get().getSharedResourcesPath(); return path.startsWith(sharedResourcesPath); }
From source file:org.brixcms.web.BrixRequestMapper.java
License:Apache License
@Override public int getCompatibilityScore(Request request) { Url url = request.getUrl(); if (url.getSegments().size() > 0) { if (url.getSegments().get(0).equals((Application.get().getMapperContext().getNamespace()))) { // starts with wicket namespace - is an internal wicket url return 0; }/* w ww. j av a 2 s . c om*/ } // bluff we can parse all segments - makes sure we run first return request.getUrl().getSegments().size(); }
From source file:org.cast.cwm.BinaryFileDataMapper.java
License:Open Source License
@Override public int getCompatibilityScore(Request request) { if (request.getUrl().toString().startsWith(urlPrefix)) return COMPATIBILITY_SCORE; return 0;//from w ww . jav a2 s .co m }
From source file:org.cast.cwm.BinaryFileDataMapper.java
License:Open Source License
@Override public IRequestHandler mapRequest(Request request) { List<String> segments = request.getUrl().getSegments(); if (segments.size() != 2) return null; if (!segments.get(0).equals(urlPrefix)) return null; Long id = Long.valueOf(segments.get(1)); return new ResourceRequestHandler(new BinaryFileDataResource(id), null); }