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

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

Introduction

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

Prototype

int SC_BAD_GATEWAY

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

Click Source Link

Document

<tt>502 Bad Gateway</tt> (HTTP/1.0 - RFC 1945)

Usage

From source file:org.alfresco.integrations.google.glass.webscripts.UploadContent.java

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>();

    String param_nodeRef = req.getParameter(PARAM_NODEREF);
    NodeRef nodeRef = new NodeRef(param_nodeRef);

    try {// w  ww .j a  v  a 2 s  . c om
        googleGlassService.uploadContent(googleGlassService.getCredential(), nodeRef);
    } catch (GoogleGlassAuthenticationException ggae) {
        throw new WebScriptException(HttpStatus.SC_BAD_GATEWAY, ggae.getMessage());
    } catch (GoogleGlassServiceException ggse) {
        if (ggse.getPassedStatusCode() > -1) {
            throw new WebScriptException(ggse.getPassedStatusCode(), ggse.getMessage());
        } else {
            throw new WebScriptException(ggse.getMessage());
        }
    } catch (GoogleGlassRefreshTokenException ggrte) {
        throw new WebScriptException(HttpStatus.SC_BAD_GATEWAY, ggrte.getMessage());
    } catch (IOException ioe) {
        throw new WebScriptException(HttpStatus.SC_INTERNAL_SERVER_ERROR, ioe.getMessage(), ioe);
    } catch (Exception e) {
        throw new WebScriptException(HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage(), e);
    }

    model.put(MODEL_NODEREF, nodeRef.toString());

    return model;
}

From source file:org.jetbrains.tfsIntegration.exceptions.TfsExceptionManager.java

public static TfsException createHttpTransportErrorException(int errorCode, AxisFault axisFault) {
    switch (errorCode) {
    case HttpStatus.SC_UNAUTHORIZED:
        return new UnauthorizedException(axisFault);
    case HttpStatus.SC_BAD_GATEWAY:
        return new HostNotFoundException(axisFault);
    case HttpStatus.SC_NOT_FOUND:
        return new HostNotApplicableException(axisFault);
    case HttpStatus.SC_FORBIDDEN:
        return new ForbiddenException(axisFault);
    case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
        return new TfsException(TFSBundle.message("proxy.auth.failed"));
    default:/*from w w  w .j a v  a 2s.com*/
        return new ConnectionFailedException(axisFault, errorCode);
    }
}

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://w w  w .  j a va  2 s  . co  m
        return 1;
    }
}