/** * Returns information about the resource's representation. Those metadata * are important for conditional method processing. The advantage over the * complete {@link Representation} class is that it is much lighter to * create. This method is only invoked if content negotiation has been * disabled as indicated by the {@link #isNegotiated()}, otherwise the {@link #getInfo(Variant)} method is invoked.<br> * <br> * The default behavior is to invoke the {@link #get()} method. * * @return Information about the resource's representation. * @throws ResourceException */ protected RepresentationInfo getInfo() throws ResourceException { return get(); }
/** * 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); } }
} else { result = put(getConverterService().applyPatch(get(), entity), variant);
} else if (isExisting()) { if (method.equals(Method.GET)) { result = get(); } else if (method.equals(Method.POST)) { result = post(getRequestEntity());
result = (Representation) variant; } else { result = get(variant);
/** * Returns a representation whose metadata will be returned to the client. * This method is only invoked if content negotiation has been disabled as * indicated by the {@link #isNegotiated()}, otherwise the {@link #head(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 head() throws ResourceException { return get(); }
/** * Returns a representation whose metadata will be returned to the client. 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 #head()} method is invoked.<br> * <br> * The default implementation directly returns the variant if it is already * an instance of {@link Representation}. In other cases, you need to * override this method in order to provide your own implementation. * * * @param variant * The variant whose full representation must be returned. * @return The resource's representation. * @see #get(Variant) * @throws ResourceException */ protected Representation head(Variant variant) throws ResourceException { return get(variant); }
/** * Returns information about the resource's representation. Those metadata * are important for conditional method processing. The advantage over the * complete {@link Representation} class is that it is much lighter to * create. 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 #getInfo(Variant)} method is invoked.<br> * <br> * The default behavior is to invoke the {@link #get(Variant)} method. * * @param variant * The variant whose representation information must be returned. * @return Information about the resource's representation. * @throws ResourceException */ protected RepresentationInfo getInfo(Variant variant) throws ResourceException { return get(variant); }