/** * 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; }
((ServerResource) resource).updateAllowedMethods(); methodsList.addAll(((ServerResource) resource).getAllowedMethods());
sr.updateAllowedMethods(); resource = sr;
} finally { if (Status.CLIENT_ERROR_METHOD_NOT_ALLOWED.equals(getStatus())) { updateAllowedMethods(); } else if (Status.SUCCESS_OK.equals(getStatus()) && (getResponseEntity() == null || !getResponseEntity()