/** * Returns the optionally decoded remaining part. * * @param decode * Indicates if the result should be decoded using the {@link #decode(String)} method. * @return The optionally decoded remaining part. * @see #getRemainingPart() */ public String getRemainingPart(boolean decode) { return getRemainingPart(decode, true); }
/** * Returns the optionally decoded remaining part. * * @param decode * Indicates if the result should be decoded using the * {@link #decode(String)} method. * @return The optionally decoded remaining part. * @see #getRemainingPart() */ public String getRemainingPart(boolean decode) { return getRemainingPart(true, true); }
/** * Returns the optionally decoded remaining part. * * @param decode * Indicates if the result should be decoded using the * {@link #decode(String)} method. * @return The optionally decoded remaining part. * @see #getRemainingPart() */ public String getRemainingPart(boolean decode) { return getRemainingPart(true, true); }
/** * Returns the part of the resource identifier remaining after the base * reference. Note that the optional fragment is not returned by this * method. Must be used with the following prerequisites: * <ul> * <li>the reference is absolute</li> * <li>the reference identifier starts with the resource baseRef</li> * </ul> * <br> * Note that no URI decoding is done by this method. * * @return The remaining resource part or null if the prerequisites are not * satisfied. * @see #getRemainingPart(boolean) */ public String getRemainingPart() { return getRemainingPart(false, true); }
/** * Returns the part of the resource identifier remaining after the base * reference. Note that the optional fragment is not returned by this * method. Must be used with the following prerequisites: * <ul> * <li>the reference is absolute</li> * <li>the reference identifier starts with the resource baseRef</li> * </ul> * <br> * Note that no URI decoding is done by this method. * * @return The remaining resource part or null if the prerequisites are not * satisfied. * @see #getRemainingPart(boolean) */ public String getRemainingPart() { return getRemainingPart(false, true); }
/** * Returns the part of the resource identifier remaining after the base * reference. Note that the optional fragment is not returned by this * method. Must be used with the following prerequisites: * <ul> * <li>the reference is absolute</li> * <li>the reference identifier starts with the resource baseRef</li> * </ul> * <br> * Note that no URI decoding is done by this method. * * @return The remaining resource part or null if the prerequisites are not * satisfied. * @see #getRemainingPart(boolean) */ public String getRemainingPart() { return getRemainingPart(false, true); }
private String getPath(final Request request) { return request.getResourceRef().getRemainingPart(false, false); }
protected String getResourceStorePath(Request request) { try { // #getRemainingPart(true, true) would use Restlet decoding, that relies // on same URLDecoder as below, but without this "trick" below // source: http://stackoverflow.com/questions/2632175/java-decoding-uri-query-string final String remainingPart = request.getResourceRef().getRemainingPart(false, false); final String remainingDecodedPart = URLDecoder.decode(remainingPart.replace("+", "%2B"), "UTF-8").replace("%2B", "+"); return parsePathFromUri(remainingDecodedPart); } catch (UnsupportedEncodingException e) { throw new IllegalStateException( "Nexus cannot operate on platform not supporting UTF-8 character encoding!", e); } }
protected String getResourceStorePath( Request request ) { try { // #getRemainingPart(true, true) would use Restlet decoding, that relies // on same URLDecoder as below, but without this "trick" below // source: http://stackoverflow.com/questions/2632175/java-decoding-uri-query-string final String remainingPart = request.getResourceRef().getRemainingPart( false, false ); final String remainingDecodedPart = URLDecoder.decode( remainingPart.replace( "+", "%2B" ), "UTF-8" ).replace( "%2B", "+" ); return parsePathFromUri( remainingDecodedPart ); } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException( "Nexus cannot operate on platform not supporting UTF-8 character encoding!", e ); } }
protected String getResourceStorePath(Request request) throws ResourceException { String path = null; if (getRepositoryId(request) != null || getRepositoryGroupId(request) != null) { path = request.getResourceRef().getRemainingPart(); // get rid of query part if (path.contains("?")) { path = path.substring(0, path.indexOf('?')); } // get rid of reference part if (path.contains("#")) { path = path.substring(0, path.indexOf('#')); } if (StringUtils.isEmpty(path)) { path = "/"; } } return path; }
protected String getResourceStorePath(Request request) throws ResourceException { String path = null; if (getRepositoryId(request) != null || getRepositoryGroupId(request) != null) { path = request.getResourceRef().getRemainingPart(); // get rid of query part if (path.contains("?")) { path = path.substring(0, path.indexOf('?')); } // get rid of reference part if (path.contains("#")) { path = path.substring(0, path.indexOf('#')); } if (StringUtils.isEmpty(path)) { path = "/"; } } return path; }
protected String getResourceStorePath( Request request ) throws ResourceException { String path = null; if ( getRepositoryId( request ) != null || getRepositoryGroupId( request ) != null ) { path = request.getResourceRef().getRemainingPart(); // get rid of query part if ( path.contains( "?" ) ) { path = path.substring( 0, path.indexOf( '?' ) ); } // get rid of reference part if ( path.contains( "#" ) ) { path = path.substring( 0, path.indexOf( '#' ) ); } if ( StringUtils.isEmpty( path ) ) { path = "/"; } } return path; }
protected String getResourceStorePath( Request request ) throws ResourceException { String path = null; if ( getRepositoryId( request ) != null || getRepositoryGroupId( request ) != null ) { path = request.getResourceRef().getRemainingPart(); // get rid of query part if ( path.contains( "?" ) ) { path = path.substring( 0, path.indexOf( '?' ) ); } // get rid of reference part if ( path.contains( "#" ) ) { path = path.substring( 0, path.indexOf( '#' ) ); } if ( StringUtils.isEmpty( path ) ) { path = "/"; } } return path; }
@Get("txt") public String hello() { List<Car> cars = carService.list(); List<String> carNames = cars.stream().map(Car::getName).collect(toList()); return "Resource URI : " + getReference() + '\n' + "Root URI : " + getRootRef() + '\n' + "Routed part : " + getReference().getBaseRef() + '\n' + "Remaining part: " + getReference().getRemainingPart() + '\n' + carNames.toString(); } }
/** * Indicates if the request is an attempt to log in and should be intercepted. * * @param request * The current request. * @param response * The current response. * @return True if the request is an attempt to log in and should be intercepted. */ protected boolean isLoggingIn(final Request request, final Response response) { return this.isInterceptingLogin() && this.getLoginPath().equals(request.getResourceRef().getRemainingPart(false, false)) && Method.POST.equals(request.getMethod()); }
/** * Returns the resource's relative path. * * @return The resource's relative path. */ protected String getResourcePath() { Reference ref = new Reference(getRequest().getRootRef(), getRequest() .getResourceRef()); return ref.getRemainingPart(); }
/** * Indicates if the request is an attempt to log out and should be intercepted. * * @param request * The current request. * @param response * The current response. * @return True if the request is an attempt to log out and should be intercepted. */ protected boolean isLoggingOut(final Request request, final Response response) { return this.isInterceptingLogout() && this.getLogoutPath().equals(request.getResourceRef().getRemainingPart(false, false)) && (Method.GET.equals(request.getMethod()) || Method.POST.equals(request.getMethod())); }
@Get public String toString() { // Print the requested URI path return "Resource URI : " + getReference() + '\n' + "Root URI : " + getRootRef() + '\n' + "Routed part : " + getReference().getBaseRef() + '\n' + "Remaining part: " + getReference().getRemainingPart(); }
/** * Allows filtering before processing by the next Restlet. Set the base * reference. * * @param request * The request to handle. * @param response * The response to update. * @return The continuation status. */ @Override protected int beforeHandle(Request request, Response response) { if (request.getHostRef() == null) { request.getResourceRef().setBaseRef( request.getResourceRef().getHostIdentifier()); } else { request.getResourceRef().setBaseRef(request.getHostRef()); } if (request.isLoggable() && getLogger().isLoggable(Level.FINE)) { getLogger().fine( "Base URI: \"" + request.getResourceRef().getBaseRef() + "\". Remaining part: \"" + request.getResourceRef().getRemainingPart() + "\""); } return CONTINUE; }
/** * Implementation of algorithm in JAX-RS-Spec (2008-04-16), Section 3.7.2 * "Request Matching" * * @return (Sub)Resource Method * @throws RequestHandledException * @throws WebApplicationException */ private ResObjAndMeth requestMatching() throws RequestHandledException, WebApplicationException { Request restletRequest = tlContext.get().getRequest(); // Part 1 RemainingPath u = new RemainingPath(restletRequest.getResourceRef() .getRemainingPart()); RroRemPathAndMatchedPath rrm = identifyRootResource(u); // Part 2 ResObjAndRemPath resourceObjectAndPath = obtainObject(rrm); Representation entity = restletRequest.getEntity(); // Part 3 MediaType givenMediaType; if (entity != null) givenMediaType = entity.getMediaType(); else givenMediaType = null; ResObjAndMeth method = identifyMethod(resourceObjectAndPath, givenMediaType); return method; }