Example usage for org.apache.commons.httpclient HttpStatus SC_REQUESTED_RANGE_NOT_SATISFIABLE

List of usage examples for org.apache.commons.httpclient HttpStatus SC_REQUESTED_RANGE_NOT_SATISFIABLE

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpStatus SC_REQUESTED_RANGE_NOT_SATISFIABLE.

Prototype

int SC_REQUESTED_RANGE_NOT_SATISFIABLE

To view the source code for org.apache.commons.httpclient HttpStatus SC_REQUESTED_RANGE_NOT_SATISFIABLE.

Click Source Link

Document

<tt>416 Requested Range Not Satisfiable</tt> (HTTP/1.1 - RFC 2616)

Usage

From source file:com.bigdata.rdf.sail.remoting.GraphRepositoryServlet.java

/**
 * Perform an HTTP-DELETE, which corresponds to the basic CRUD operation
 * "delete" according to the generic interaction semantics of HTTP REST.
 * <p>/*from   ww  w .ja  v  a  2  s.  co m*/
 * BODY ignored for DELETE 
 * RANGE of null clears the entire graph
 * RANGE(triples[<rdf/xml>]) deletes the selection specified by the serialized triples
 * RANGE(query[<query language>[<query string>]]) deletes the selection specified by the query
 */
protected void doDelete(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // DELETE
    String range = request.getHeader("RANGE");

    if (log.isInfoEnabled()) {
        log.info("range header: " + range);
    }

    try {
        if (range == null || range.length() == 0) {
            clear();
        } else if (range.startsWith("triples[")) {
            // chop off the "triples[" at the beginning
            // and the "]" at the end
            final String rdfXml = range.substring(8, range.length() - 1);
            delete(rdfXml);
        } else if (range.startsWith("query[")) {
            // chop off the "query[" at the beginning
            // and the "]" at the end
            range = range.substring(6, range.length() - 1);
            final int i = range.indexOf('[');
            final QueryLanguage ql = QueryLanguage.valueOf(range.substring(0, i));
            if (ql == null) {
                throw new RuntimeException("unrecognized query language: " + range);
            }
            final String query = range.substring(i + 1, range.length() - 1);
            deleteByQuery(query, ql);
        } else {
            response.sendError(HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE,
                    "unrecognized subgraph selection scheme in range header");
            return;
        }
        response.setStatus(HttpStatus.SC_OK);
    } catch (Exception ex) {
        ex.printStackTrace();
        response.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR, ex.getMessage());
    }
}

From source file:org.opens.tanaguru.util.http.HttpRequestHandler.java

private int computeStatus(int status) {
    switch (status) {
    case HttpStatus.SC_FORBIDDEN:
    case HttpStatus.SC_METHOD_NOT_ALLOWED:
    case HttpStatus.SC_BAD_REQUEST:
    case HttpStatus.SC_UNAUTHORIZED:
    case HttpStatus.SC_PAYMENT_REQUIRED:
    case HttpStatus.SC_NOT_FOUND:
    case HttpStatus.SC_NOT_ACCEPTABLE:
    case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
    case HttpStatus.SC_REQUEST_TIMEOUT:
    case HttpStatus.SC_CONFLICT:
    case HttpStatus.SC_GONE:
    case HttpStatus.SC_LENGTH_REQUIRED:
    case HttpStatus.SC_PRECONDITION_FAILED:
    case HttpStatus.SC_REQUEST_TOO_LONG:
    case HttpStatus.SC_REQUEST_URI_TOO_LONG:
    case HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE:
    case HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE:
    case HttpStatus.SC_EXPECTATION_FAILED:
    case HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE:
    case HttpStatus.SC_METHOD_FAILURE:
    case HttpStatus.SC_UNPROCESSABLE_ENTITY:
    case HttpStatus.SC_LOCKED:
    case HttpStatus.SC_FAILED_DEPENDENCY:
    case HttpStatus.SC_INTERNAL_SERVER_ERROR:
    case HttpStatus.SC_NOT_IMPLEMENTED:
    case HttpStatus.SC_BAD_GATEWAY:
    case HttpStatus.SC_SERVICE_UNAVAILABLE:
    case HttpStatus.SC_GATEWAY_TIMEOUT:
    case HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED:
    case HttpStatus.SC_INSUFFICIENT_STORAGE:
        return 0;
    case HttpStatus.SC_CONTINUE:
    case HttpStatus.SC_SWITCHING_PROTOCOLS:
    case HttpStatus.SC_PROCESSING:
    case HttpStatus.SC_OK:
    case HttpStatus.SC_CREATED:
    case HttpStatus.SC_ACCEPTED:
    case HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION:
    case HttpStatus.SC_NO_CONTENT:
    case HttpStatus.SC_RESET_CONTENT:
    case HttpStatus.SC_PARTIAL_CONTENT:
    case HttpStatus.SC_MULTI_STATUS:
    case HttpStatus.SC_MULTIPLE_CHOICES:
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_MOVED_TEMPORARILY:
    case HttpStatus.SC_SEE_OTHER:
    case HttpStatus.SC_NOT_MODIFIED:
    case HttpStatus.SC_USE_PROXY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        return 1;
    default:/*from  w w  w.j av a  2s  .  c  o m*/
        return 1;
    }
}