/** * Returns the first annotation descriptor matching the given method. * * @param method * The method to match. * @return The annotation descriptor. * @throws IOException */ private MethodAnnotationInfo getAnnotation(Method method) throws IOException { return getAnnotation(method, getQuery(), null); }
/** * 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); }
/** * 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); } }
.isCompatible(method, getQuery(), getRequestEntity(), getMetadataService(),
result = options(); } else { result = doHandle(method, getQuery(), getRequestEntity());