Java Code Examples for org.apache.olingo.odata2.api.commons.HttpStatusCodes#METHOD_NOT_ALLOWED

The following examples show how to use org.apache.olingo.odata2.api.commons.HttpStatusCodes#METHOD_NOT_ALLOWED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataExceptionMapperImpl.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private ODataErrorContext createErrorContext(final WebApplicationException exception) {
  ODataErrorContext context = new ODataErrorContext();
  if (uriInfo != null) {
    context.setRequestUri(uriInfo.getRequestUri());
  }
  if (httpHeaders != null && httpHeaders.getRequestHeaders() != null) {
    MultivaluedMap<String, String> requestHeaders = httpHeaders.getRequestHeaders();
    Set<Entry<String, List<String>>> entries = requestHeaders.entrySet();
    for (Entry<String, List<String>> entry : entries) {
      context.putRequestHeader(entry.getKey(), entry.getValue());
    }
  }
  context.setContentType(getContentType().toContentTypeString());
  context.setException(exception);
  context.setErrorCode(null);
  context.setMessage(exception.getMessage());
  context.setLocale(DEFAULT_RESPONSE_LOCALE);
  HttpStatusCodes statusCode = HttpStatusCodes.fromStatusCode(exception.getResponse().getStatus());
  context.setHttpStatus(statusCode);
  if (statusCode == HttpStatusCodes.METHOD_NOT_ALLOWED) {
    // RFC 2616, 5.1.1: " An origin server SHOULD return the status code
    // 405 (Method Not Allowed) if the method is known by the origin server
    // but not allowed for the requested resource, and 501 (Not Implemented)
    // if the method is unrecognized or not implemented by the origin server."
    // Since all recognized methods are handled elsewhere, we unconditionally
    // switch to 501 here for not-allowed exceptions thrown directly from
    // JAX-RS implementations.
    context.setHttpStatus(HttpStatusCodes.NOT_IMPLEMENTED);
    context.setMessage("The request dispatcher does not allow the HTTP method used for the request.");
    context.setLocale(Locale.ENGLISH);
  }
  return context;
}
 
Example 2
Source File: ODataMethodNotAllowedException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataMethodNotAllowedException(final MessageReference messageReference) {
  super(messageReference, HttpStatusCodes.METHOD_NOT_ALLOWED);
}
 
Example 3
Source File: ODataMethodNotAllowedException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataMethodNotAllowedException(final MessageReference messageReference, final Throwable cause) {
  super(messageReference, cause, HttpStatusCodes.METHOD_NOT_ALLOWED);
}
 
Example 4
Source File: ODataMethodNotAllowedException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataMethodNotAllowedException(final MessageReference messageReference, final String errorCode) {
  super(messageReference, HttpStatusCodes.METHOD_NOT_ALLOWED, errorCode);
}
 
Example 5
Source File: ODataMethodNotAllowedException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataMethodNotAllowedException(final MessageReference messageReference, final Throwable cause,
    final String errorCode) {
  super(messageReference, cause, HttpStatusCodes.METHOD_NOT_ALLOWED, errorCode);
}