/** * Indicates if the identifier is hierarchical. * * @return True if the identifier is hierarchical, false if it is opaque. */ public boolean isHierarchical() { return isRelative() || (getSchemeSpecificPart().charAt(0) == '/'); }
/** * Returns the relative part of relative references, without the query and * fragment. If the reference is absolute, then null is returned.<br> * Note that no URI decoding is done by this method. * * @return The relative part. */ public String getRelativePart() { return isRelative() ? toString(false, false) : null; }
/** * Indicates if the identifier is hierarchical. * * @return True if the identifier is hierarchical, false if it is opaque. */ public boolean isHierarchical() { return isRelative() || (getSchemeSpecificPart().charAt(0) == '/'); }
/** * Returns the relative part of relative references, without the query and * fragment. If the reference is absolute, then null is returned.<br> * Note that no URI decoding is done by this method. * * @return The relative part. */ public String getRelativePart() { return isRelative() ? toString(false, false) : null; }
/** * Returns the relative part of relative references, without the query and * fragment. If the reference is absolute, then null is returned.<br> * Note that no URI decoding is done by this method. * * @return The relative part. */ public String getRelativePart() { return isRelative() ? toString(false, false) : null; }
/** * Indicates if the identifier is hierarchical. * * @return True if the identifier is hierarchical, false if it is opaque. */ public boolean isHierarchical() { return isRelative() || (getSchemeSpecificPart().charAt(0) == '/'); }
/** * Returns the authority component for hierarchical identifiers. Includes * the user info, host name and the host port number.<br> * Note that no URI decoding is done by this method. * * @return The authority component for hierarchical identifiers. */ public String getAuthority() { final String part = isRelative() ? getRelativePart() : getSchemeSpecificPart(); if ((part != null) && part.startsWith("//")) { int index = part.indexOf('/', 2); if (index != -1) { return part.substring(2, index); } index = part.indexOf('?'); if (index != -1) { return part.substring(2, index); } return part.substring(2); } return null; }
/** * Returns the authority component for hierarchical identifiers. Includes * the user info, host name and the host port number.<br> * Note that no URI decoding is done by this method. * * @return The authority component for hierarchical identifiers. */ public String getAuthority() { final String part = isRelative() ? getRelativePart() : getSchemeSpecificPart(); if ((part != null) && part.startsWith("//")) { int index = part.indexOf('/', 2); if (index != -1) { return part.substring(2, index); } index = part.indexOf('?'); if (index != -1) { return part.substring(2, index); } return part.substring(2); } return null; }
/** * Returns the authority component for hierarchical identifiers. Includes * the user info, host name and the host port number.<br> * Note that no URI decoding is done by this method. * * @return The authority component for hierarchical identifiers. */ public String getAuthority() { final String part = isRelative() ? getRelativePart() : getSchemeSpecificPart(); if ((part != null) && part.startsWith("//")) { int index = part.indexOf('/', 2); if (index != -1) { return part.substring(2, index); } index = part.indexOf('?'); if (index != -1) { return part.substring(2, index); } return part.substring(2); } return null; }
String part = isRelative() ? getRelativePart() : getSchemeSpecificPart();
String part = isRelative() ? getRelativePart() : getSchemeSpecificPart();
final String oldPart = isRelative() ? getRelativePart() : getSchemeSpecificPart(); String newPart;
final String oldPart = isRelative() ? getRelativePart() : getSchemeSpecificPart(); String newPart;
final String oldPart = isRelative() ? getRelativePart() : getSchemeSpecificPart(); String newPart;
HandlerCommand query( Link link, Object queryRequest, ResponseHandler handler, ResponseHandler processingErrorHandler ) { if (handler == null) handler = queryHandlers.get( link.rel().get() ); if (handler == null) throw new IllegalArgumentException( "No handler set for relation "+link.rel().get() ); if (processingErrorHandler == null) processingErrorHandler = processingErrorHandlers.get( link.rel().get() ); Reference linkRef = new Reference(link.href().get()); if (linkRef.isRelative()) linkRef = new Reference( reference.toUri().toString() + link.href().get() ); return invokeQuery( linkRef, queryRequest, handler, processingErrorHandler ); }
/** * Returns the child resource defined by its URI relatively to the current * resource. The child resource is defined in the sense of hierarchical * URIs. If the resource URI is not hierarchical, then an exception is * thrown. * * @param relativeRef * The URI reference of the child resource relatively to the * current resource seen as the parent resource. * @return The child resource. * @throws ResourceException */ public ClientResource getChild(Reference relativeRef) throws ResourceException { ClientResource result = null; if ((relativeRef != null) && relativeRef.isRelative()) { result = new ClientResource(this); result.setReference(new Reference(getReference().getTargetRef(), relativeRef).getTargetRef()); } else { doError(Status.CLIENT_ERROR_BAD_REQUEST, "The child URI is not relative."); } return result; }
/** * Returns the target reference to redirect to by automatically resolving * URI template variables found using the {@link Template} class using the * request and response as data models. * * @param request * The request to handle. * @param response * The response to update. * @return The target reference to redirect to. */ protected Reference getTargetRef(Request request, Response response) { // Create the template Template rt = new Template(this.targetTemplate); rt.setLogger(getLogger()); // Return the formatted target URI if (new Reference(this.targetTemplate).isRelative()) { // Be sure to keep the resource's base reference. return new Reference(request.getResourceRef(), rt.format(request, response)); } return new Reference(rt.format(request, response)); }
/** * Returns the feed representation. * * @return The feed representation. * @throws Exception */ public Feed getFeed() throws Exception { final Reference feedRef = getHref(); if (feedRef.isRelative()) { feedRef.setBaseRef(getWorkspace().getService().getReference()); } final Request request = new Request(Method.GET, feedRef.getTargetRef()); final Response response = getWorkspace().getService() .getClientDispatcher().handle(request); if (response.getStatus().equals(Status.SUCCESS_OK)) { return new Feed(response.getEntity()); } throw new Exception( "Couldn't get the feed representation. Status returned: " + response.getStatus()); }
/** * Returns the feed representation. * * @return The feed representation. * @throws Exception */ public Feed getFeed() throws Exception { final Reference feedRef = getHref(); if (feedRef.isRelative()) { feedRef.setBaseRef(getWorkspace().getService().getReference()); } final Request request = new Request(Method.GET, feedRef.getTargetRef()); final Response response = getWorkspace().getService() .getClientDispatcher().handle(request); if (response.getStatus().equals(Status.SUCCESS_OK)) { return new Feed(response.getEntity()); } throw new Exception( "Couldn't get the feed representation. Status returned: " + response.getStatus()); }
/** * Returns the feed representation. * * @return The feed representation. * @throws Exception */ public Feed getFeed() throws Exception { final Reference feedRef = getHref(); if (feedRef.isRelative()) { feedRef.setBaseRef(getWorkspace().getService().getReference()); } final Request request = new Request(Method.GET, feedRef.getTargetRef()); final Response response = getWorkspace().getService() .getClientDispatcher().handle(request); if (response.getStatus().equals(Status.SUCCESS_OK)) { return new Feed(response.getEntity()); } else { throw new Exception( "Couldn't get the feed representation. Status returned: " + response.getStatus().getDescription()); } }