Example usage for javax.servlet.http HttpServletResponse SC_OK

List of usage examples for javax.servlet.http HttpServletResponse SC_OK

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse SC_OK.

Prototype

int SC_OK

To view the source code for javax.servlet.http HttpServletResponse SC_OK.

Click Source Link

Document

Status code (200) indicating the request succeeded normally.

Usage

From source file:com.sixt.service.framework.json.JsonUtil.java

public static JsonRpcResponse parseJsonRpcResponse(String rawResponse) {
    JsonParser parser = new JsonParser();
    JsonObject response = parser.parse(rawResponse).getAsJsonObject();
    JsonElement id = response.get("id");
    JsonElement errorElement = response.get("error");
    int responseStatus = HttpServletResponse.SC_OK;
    String error;//from   w w w . ja  v  a 2s  .  c  o  m
    if (!(errorElement instanceof JsonNull)) {
        if (errorElement instanceof JsonObject) {
            error = errorElement.toString();
            // try parsing it into RpcCallException to get the HttpStatus from there
            RpcCallException rpcEx = RpcCallException.fromJson(error);
            if (rpcEx != null) {
                responseStatus = rpcEx.getCategory().getHttpStatus();
                JsonElement resultElement = response.get("result");
                return new JsonRpcResponse(id, resultElement == null ? JsonNull.INSTANCE : resultElement,
                        errorElement, responseStatus);
            }
        }
        error = errorElement.getAsString();
        if (StringUtils.isNotBlank(error)) {
            responseStatus = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        }
    }

    JsonElement resultElement = response.get("result");
    return new JsonRpcResponse(id, resultElement == null ? JsonNull.INSTANCE : resultElement, errorElement,
            responseStatus);
}

From source file:com.tamnd.app.config.security.LogoutSuccessHandler.java

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) {
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:com.tamnd.app.config.security.AuthSuccess.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:com.skcraft.launcher.creator.server.LatestHandler.java

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    response.setContentType("text/plain; charset=utf-8");
    response.setStatus(HttpServletResponse.SC_OK);

    LatestVersionInfo info = new LatestVersionInfo();
    info.setVersion("0.0.0");
    info.setUrl(new URL("http://localhost"));
    mapper.writeValue(response.getWriter(), info);

    baseRequest.setHandled(true);//w  ww  . ja  v  a2s.com
}

From source file:com.lennonjesus.auth.security.handler.AjaxAuthenticationSuccessHandler.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    logger.debug("Authentication Successful");
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:com.lennonjesus.auth.security.handler.AjaxLogoutSuccessHandler.java

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    logger.debug("Logout Successful");
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:com.whatsthatlight.teamcity.hipchat.test.SimpleServerTest.java

@Test
public void testTestServer() throws Exception {
    // Test parameters
    String expectedResponse = "<h1>Hello World</h1>";
    int expectedStatusCode = HttpServletResponse.SC_OK;
    int port = 8080;
    URI uri = new URI(String.format("http://localhost:%s/", port));

    // Setup//  w  w w  .jav a  2s  .  c o m
    SimpleServer server = new SimpleServer(port, new SimpleHandler(expectedResponse, expectedStatusCode));
    server.start();

    // Make request
    HttpClient client = HttpClientBuilder.create().build();
    HttpGet getRequest = new HttpGet(uri.toString());
    HttpResponse getResponse = client.execute(getRequest);
    int actualStatusCode = getResponse.getStatusLine().getStatusCode();
    String actualResponse = EntityUtils.toString(getResponse.getEntity());

    // Clean up
    server.stop();

    // Test
    assertEquals(expectedStatusCode, actualStatusCode);
    assertEquals(expectedResponse, actualResponse);
}

From source file:com.company.project.web.controller.service.HttpLogoutSuccessHandler.java

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException {
    response.setStatus(HttpServletResponse.SC_OK);
    response.getWriter().flush();//from   w w w . ja  v  a2s.  co m
}

From source file:org.chtijbug.drools.platform.web.security.Http200AuthenticationSuccessHandler.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_OK);
    response.getWriter().write(authentication.getName());
}

From source file:com.nesscomputing.tracking.adapters.ResponseCodeCheckingConverter.java

ResponseCodeCheckingConverter() {
    this(HttpServletResponse.SC_OK);
}