/** * Posts a representation to the resource at the target URI reference. This * method is only invoked if content negotiation has been disabled as * indicated by the {@link #isNegotiated()}, otherwise the {@link #post(Representation, Variant)} method is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}. * * @param entity * The posted entity. * @return The optional response entity. * @throws ResourceException * @see #get(Variant) * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5">HTTP POST method</a> */ protected Representation post(Representation entity) throws ResourceException { return doHandle(Method.POST, getQuery(), entity); }
/** * Creates or updates a resource with the given representation as new state * to be stored. This method is only invoked if content negotiation has been * disabled as indicated by the {@link #isNegotiated()}, otherwise the {@link #put(Representation, Variant)} method * is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}. * * @param entity * The representation to store. * @return The optional result entity. * @throws ResourceException * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6">HTTP PUT method</a> */ protected Representation put(Representation entity) throws ResourceException { return doHandle(Method.PUT, getQuery(), entity); }
/** * Returns a full representation for a given variant. A variant parameter is * passed to indicate which representation should be returned if any.<br> * <br> * This method is only invoked if content negotiation has been enabled as * indicated by the {@link #isNegotiated()}, otherwise the {@link #get()} method is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}.<br> * * @param variant * The variant whose full representation must be returned. * @return The resource's representation. * @see #get(Variant) * @throws ResourceException */ protected Representation get(Variant variant) throws ResourceException { Representation result = null; if (variant instanceof VariantInfo) { result = doHandle(((VariantInfo) variant).getAnnotationInfo(), variant); } else { doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } return result; }
/** * Deletes the resource and all its representations. A variant parameter is * passed to indicate which representation should be returned if any.<br> * <br> * This method is only invoked if content negotiation has been enabled as * indicated by the {@link #isNegotiated()}, otherwise the {@link #delete()} method is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}. * * @param variant * The variant of the response entity. * @return The optional response entity. * @throws ResourceException * @see #get(Variant) * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7" >HTTP DELETE method</a> */ protected Representation delete(Variant variant) throws ResourceException { Representation result = null; if (variant instanceof VariantInfo) { result = doHandle(((VariantInfo) variant).getAnnotationInfo(), variant); } else { doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } return result; }
/** * Posts a representation to the resource at the target URI reference. A * variant parameter is passed to indicate which representation should be * returned if any.<br> * <br> * This method is only invoked if content negotiation has been enabled as * indicated by the {@link #isNegotiated()}, otherwise the {@link #post(Representation)} method is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}.<br> * * @param entity * The posted entity. * @param variant * The variant of the response entity. * @return The optional result entity. * @throws ResourceException * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5" >HTTP POST method</a> */ protected Representation post(Representation entity, Variant variant) throws ResourceException { Representation result = null; if (variant instanceof VariantInfo) { result = doHandle(((VariantInfo) variant).getAnnotationInfo(), variant); } else { doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } return result; }
result = doHandle(((VariantInfo) variant).getAnnotationInfo(), variant); } else {
/** * Returns a descriptor of the response entity returned by a {@link Method#GET} call. * * @return The response entity. * @throws ResourceException */ private RepresentationInfo doGetInfo() throws ResourceException { RepresentationInfo result = null; MethodAnnotationInfo annotationInfo; try { annotationInfo = getAnnotation(Method.GET); if (annotationInfo != null) { result = doHandle(annotationInfo, null); } else { result = getInfo(); } } catch (IOException e) { throw new ResourceException(e); } return result; }
/** * Returns a descriptor of the response entity returned by a negotiated {@link Method#GET} call. * * @param variant * The selected variant descriptor. * @return The response entity descriptor. * @throws ResourceException */ private RepresentationInfo doGetInfo(Variant variant) throws ResourceException { RepresentationInfo result = null; if (variant != null) { if (variant instanceof VariantInfo) { result = doHandle(((VariantInfo) variant).getAnnotationInfo(), variant); } else if (variant instanceof RepresentationInfo) { result = (RepresentationInfo) variant; } else { result = getInfo(variant); } } else { result = doGetInfo(); } return result; }
/** * Deletes the resource and all its representations. This method is only * invoked if content negotiation has been disabled as indicated by the {@link #isNegotiated()}, otherwise the * {@link #delete(Variant)} method is * invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}. * * @return The optional response entity. * @throws ResourceException * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7" >HTTP DELETE method</a> */ protected Representation delete() throws ResourceException { Representation result = null; MethodAnnotationInfo annotationInfo; try { annotationInfo = getAnnotation(Method.DELETE); if (annotationInfo != null) { result = doHandle(annotationInfo, null); } else { doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new ResourceException(e); } return result; }
/** * Returns a full representation. This method is only invoked if content * negotiation has been disabled as indicated by the {@link #isNegotiated()} , otherwise the {@link #get(Variant)} * method is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}. * * @return The resource's representation. * @throws ResourceException * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3">HTTP GET method</a> */ protected Representation get() throws ResourceException { Representation result = null; MethodAnnotationInfo annotationInfo; try { annotationInfo = getAnnotation(Method.GET); if (annotationInfo != null) { result = doHandle(annotationInfo, null); } else { doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new ResourceException(e); } return result; }
/** * Indicates the communication options available for this resource. A * variant parameter is passed to indicate which representation should be * returned if any.<br> * <br> * This method is only invoked if content negotiation has been enabled as * indicated by the {@link #isNegotiated()}, otherwise the {@link #options()} method is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}.<br> * * @param variant * The variant of the response entity. * @return The optional response entity. * @see #get(Variant) */ protected Representation options(Variant variant) throws ResourceException { Representation result = null; // Updates the list of allowed methods updateAllowedMethods(); if (variant instanceof VariantInfo) { result = doHandle(((VariantInfo) variant).getAnnotationInfo(), variant); } else { doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } return result; }
/** * Indicates the communication options available for this resource. This * method is only invoked if content negotiation has been disabled as * indicated by the {@link #isNegotiated()}, otherwise the {@link #options(Variant)} method is invoked.<br> * <br> * The default behavior is to set the response status to * {@link org.restlet.data.Status#CLIENT_ERROR_METHOD_NOT_ALLOWED}. * * @return The optional response entity. */ protected Representation options() throws ResourceException { Representation result = null; MethodAnnotationInfo annotationInfo; try { annotationInfo = getAnnotation(Method.OPTIONS); // Updates the list of allowed methods updateAllowedMethods(); if (annotationInfo != null) { result = doHandle(annotationInfo, null); } else { doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new ResourceException(e); } return result; }
result = doHandle(annotationInfo, null); } else {
result = doHandle(((VariantInfo) variant).getAnnotationInfo(), variant); } else {
/** * Apply a patch entity to the current representation of the resource * retrieved by calling {@link #get()}. By default, the * {@link ConverterService#applyPatch(Representation, Representation)} method is used and then the * {@link #put(Representation)} method called. * * @param entity * The patch entity to apply. * @return The optional result entity. * @throws ResourceException * @see <a href="https://tools.ietf.org/html/rfc5789">HTTP PATCH method</a> */ protected Representation patch(Representation entity) throws ResourceException { AnnotationInfo annotationInfo; try { annotationInfo = getAnnotation(Method.PATCH); if (annotationInfo != null) { return doHandle(Method.PATCH, getQuery(), entity); } else { // Default implementation return put(getConverterService().applyPatch(get(), entity)); // doError(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new ResourceException(e); } }
result = doNegotiatedHandle(); } else { result = doHandle();
result = options(); } else { result = doHandle(method, getQuery(), getRequestEntity());
result = doHandle( ((VariantInfo) variant).getAnnotationInfo(), variant);