/** * unwraps the restlet passed to dispatched() to find the actual target. */ Restlet unwrap(Restlet next) { if (next instanceof Route) { next = ((Route)next).getNext(); } if (next instanceof BeanDelegatingRestlet) { next = ((BeanDelegatingRestlet) next).getBean(); } return next; }
float result = 0F; if ((getRouter() != null) && (request.getResourceRef() != null) && (getTemplate() != null)) { final String remainingPart = request.getResourceRef() .getRemainingPart(false, getMatchQuery()); if (remainingPart != null) { final int matchedLength = getTemplate().match(remainingPart); result = getRouter().getRequiredScore() + (1.0F - getRouter().getRequiredScore()) if (getLogger().isLoggable(Level.FINER)) { getLogger().finer( "Call score for the \"" + getTemplate().getPattern() + "\" URI pattern: " + result);
/** * Creates a new route for the given URI pattern and target. * * @param uriPattern * The URI pattern that must match the relative part of the * resource URI. * @param target * The target Restlet to attach. * @return The created route. */ protected Route createRoute(String uriPattern, Restlet target) { final Route result = new Route(this, uriPattern, target); result.getTemplate().setMatchingMode(getDefaultMatchingMode()); result.setMatchQuery(this.defaultMatchQuery); return result; }
if (getTemplate() != null) { final String remainingPart = request.getResourceRef() .getRemainingPart(false, getMatchQuery()); final int matchedLength = getTemplate().parse(remainingPart, request); if (getLogger().isLoggable(Level.FINER)) { getLogger().finer( "Attempting to match this pattern: " + getTemplate().getPattern() + " >> " + matchedLength); if (getLogger().isLoggable(Level.FINE)) { getLogger().fine( "New base URI: " + request.getResourceRef().getBaseRef()); getLogger().fine( "New remaining part: " + request.getResourceRef() .getRemainingPart(false, getMatchQuery())); if (getLogger().isLoggable(Level.FINE)) { getLogger().fine( "Delegating the call to the target Restlet"); extractAttributes(request, response); validateAttributes(request, response);
for (final Route route : component.getDefaultHost() .getRoutes()) { if (route.getTemplate().getPattern() == null) { addFullServletPath = true; continue; if (!route.getTemplate().getPattern().startsWith( uriPattern)) { if (!route.getTemplate().getPattern() .startsWith(request.getServletPath())) { addFullServletPath = true; for (final Route route : virtualHost .getRoutes()) { if (route.getTemplate().getPattern() == null) { addFullServletPath = true; continue; if (!route.getTemplate().getPattern() .startsWith(uriPattern)) { if (!route .getTemplate() .getPattern() .startsWith( .getDefaultRoute(); if (defaultRoute != null) { defaultRoute.getTemplate().setPattern( offsetPath
/** * Returns the matching mode to use on the template when parsing a formatted * reference. * * @return The matching mode to use. */ public int getMatchingMode() { return getTemplate().getMatchingMode(); }
if (!getQueryExtracts().isEmpty()) { final Form form = request.getResourceRef().getQueryAsForm(); for (final ExtractInfo ei : getQueryExtracts()) { if (ei.first) { request.getAttributes().put(ei.attribute, if (!getEntityExtracts().isEmpty()) { final Form form = request.getEntityAsForm(); for (final ExtractInfo ei : getEntityExtracts()) { if (ei.first) { request.getAttributes().put(ei.attribute, if (!getCookieExtracts().isEmpty()) { final Series<Cookie> cookies = request.getCookies(); for (final ExtractInfo ei : getCookieExtracts()) { if (ei.first) { request.getAttributes().put(ei.attribute,
/** * Extracts an attribute from the request entity form. * * @param attribute * The name of the request attribute to set. * @param parameter * The name of the entity form parameter to extract. * @param first * Indicates if only the first cookie should be set. Otherwise as * a List instance might be set in the attribute value. * @return The current Filter. */ public Route extractEntity(String attribute, String parameter, boolean first) { getEntityExtracts().add(new ExtractInfo(attribute, parameter, first)); return this; }
/** * Extracts an attribute from the request cookies. * * @param attribute * The name of the request attribute to set. * @param cookieName * The name of the cookies to extract. * @param first * Indicates if only the first cookie should be set. Otherwise as * a List instance might be set in the attribute value. * @return The current Filter. */ public Route extractCookie(String attribute, String cookieName, boolean first) { getCookieExtracts().add(new ExtractInfo(attribute, cookieName, first)); return this; }
@Override protected int beforeHandle(Request request, Response response) { final int result = super.beforeHandle(request, response); // Set the request's root reference request.setRootRef(request.getResourceRef().getBaseRef()); // Save the hash code of the current host setCurrent(VirtualHost.this.hashCode()); return result; } };
/** * Sets the matching mode to use on the template when parsing a formatted * reference. * * @param matchingMode * The matching mode to use. */ public void setMatchingMode(int matchingMode) { getTemplate().setMatchingMode(matchingMode); }
private List getLinkList() { List l = new ArrayList(); Iterator it = myRouter.getRoutes().iterator(); while (it.hasNext()) { Route r = (Route) it.next(); String pattern = r.getTemplate().getPattern(); if (!pattern.contains("{") && (pattern.length() > 1)) { l.add(pattern.substring(1)); // trim leading slash } } return l; } }
@Override public void dispatched(Request request, Response response, Restlet restlet) { Method m = request.getMethod(); if (restlet instanceof Route) { restlet = ((Route) restlet).getNext(); } if (restlet instanceof BeanDelegatingRestlet) { restlet = ((BeanDelegatingRestlet) restlet).getBean(); } if (restlet != null) { // these are the restlets we have to lock if (restlet.getClass().getPackage().getName().startsWith("org.geoserver.catalog.rest")) { // choose a lok type based on the method LockType type; if ((m == Method.DELETE || m == Method.COPY || m == Method.MKCOL || m == Method.MOVE || m == Method.PROPPATCH || m == Method.POST || m == Method.PUT)) { type = LockType.WRITE; } else { type = LockType.READ; } THREAD_LOCK.set(type); locker.lock(type); } } }
final Template template = route.getTemplate(); item = childNode.getAttributes().getNamedItem( "matchingMode");
/** * Removes all routes routing to a given target. * * @param target * The target Restlet to detach. */ public synchronized void removeAll(Restlet target) { for (int i = size() - 1; i >= 0; i--) { if (get(i).getNext() == target) { remove(i); } } }
/** * Detaches the target from this router. All routes routing to this target * Restlet are removed from the list of routes and the default route is set * to null. * * @param target * The target Restlet to detach. */ public void detach(Restlet target) { getRoutes().removeAll(target); if ((getDefaultRoute() != null) && (getDefaultRoute().getNext() == target)) { setDefaultRoute(null); } }