Class HttpStatusSetter


  • public class HttpStatusSetter
    extends java.lang.Object
    HTTP Status Codes for REST.
    • Constructor Detail

      • HttpStatusSetter

        public HttpStatusSetter()
    • Method Detail

      • setStatus

        public static void setStatus​(HttpStatus httpStatus,
                                     Translet translet)
        Sets the status code.
        Parameters:
        httpStatus - the http status code
        translet - the Translet instance
      • setStatus

        public static void setStatus​(int statusCode,
                                     Translet translet)
        Sets the status code.
        Parameters:
        statusCode - the http status code
        translet - the Translet instance
      • ok

        public static void ok​(Translet translet)
        200 OK. The request has succeeded. The information returned with the response is dependent on the method used in the request, for example:
        • GET an entity corresponding to the requested resource is sent in the response;
        • HEAD the entity-header fields corresponding to the requested resource are sent in the response without any message-body;
        • POST an entity describing or containing the result of the action;
        • TRACE an entity containing the request message as received by the end server.
        Parameters:
        translet - the Translet instance
      • created

        public static void created​(Translet translet)
        201 Created. The request has succeeded and a new resource has been created as a result of it. This is typically the response sent after a PUT request.
        Parameters:
        translet - the Translet instance
      • created

        public static void created​(Translet translet,
                                   java.lang.String location)
        201 Created. The request has succeeded and a new resource has been created as a result of it. This is typically the response sent after a PUT request. The newly created resource can be referenced by the URI(s) returned in the entity of the response,with the most specific URI for the resource given by a Location header field.
        Parameters:
        translet - the Translet instance
        location - a location header set to the given URI
      • accepted

        public static void accepted​(Translet translet)
        202 Accepted. The request has been received but not yet acted upon. It is non-committal, meaning that there is no way in HTTP to later send an asynchronous response indicating the outcome of processing the request. It is intended for cases where another process or server handles the request, or for batch processing.
        Parameters:
        translet - the Translet instance
      • noContent

        public static void noContent​(Translet translet)
        204 No Content. The server successfully processed the request and is not returning any content. The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
        Parameters:
        translet - the Translet instance
      • movedPermanently

        public static void movedPermanently​(Translet translet)
        301 Moved Permanently. This response code means that URI of requested resource has been changed. Any future references to this resource SHOULD use one of the returned URIs.
        Parameters:
        translet - the Translet instance
      • seeOther

        public static void seeOther​(Translet translet)
        303 See Other. The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource. The 303 response MUST NOT be cached, but the response to the second (redirected) request might be cacheable.
        Parameters:
        translet - the Translet instance
      • notModified

        public static void notModified​(Translet translet)
        304 Not Modified. This is used for caching purposes. It is telling to client that response has not been modified. So, client can continue to use same cached version of response.
        Parameters:
        translet - the Translet instance
      • temporaryRedirect

        public static void temporaryRedirect​(Translet translet)
        307 Temporary Redirect. The target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.
        Parameters:
        translet - the Translet instance
      • badRequest

        public static void badRequest​(Translet translet)
        400 Bad Request. The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
        Parameters:
        translet - the Translet instance
      • unauthorized

        public static void unauthorized​(Translet translet)
        401 Unauthorized. The request was a legal request, but the server is refusing to respond to it. For use when authentication is possible but has failed or not yet been provided.
        Parameters:
        translet - the Translet instance
      • forbidden

        public static void forbidden​(Translet translet)
        403 Forbidden. The request was a legal request, but the server is refusing to respond to it.
        Parameters:
        translet - the Translet instance
      • notFound

        public static void notFound​(Translet translet)
        404 Not Found. The server has not found anything matching the Request-URI. The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.
        Parameters:
        translet - the Translet instance
      • methodNotAllowed

        public static void methodNotAllowed​(Translet translet)
        405 Method Not Allowed. The request method is known by the server but has been disabled and cannot be used. The two mandatory methods, GET and HEAD, must never be disabled and should not return this error code.
        Parameters:
        translet - the Translet instance
      • notAcceptable

        public static void notAcceptable​(Translet translet)
        406 Not Acceptable. The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
        Parameters:
        translet - the Translet instance
      • conflict

        public static void conflict​(Translet translet)
        409 Conflict. The request could not be completed because of a conflict.
        Parameters:
        translet - the Translet instance
      • preconditionFailed

        public static void preconditionFailed​(Translet translet)
        412 Precondition failed. The server does not meet one of the preconditions that the requester put on the request.
        Parameters:
        translet - the Translet instance
      • unsupportedMediaType

        public static void unsupportedMediaType​(Translet translet)
        415 Unsupported Media Type. The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
        Parameters:
        translet - the Translet instance
      • internalServerError

        public static void internalServerError​(Translet translet)
        500 Internal Server Error. The server encountered an unexpected condition which prevented it from fulfilling the request.
        Parameters:
        translet - the Translet instance