Java Code Examples for javax.servlet.http.HttpServletResponse#SC_ACCEPTED

The following examples show how to use javax.servlet.http.HttpServletResponse#SC_ACCEPTED . These examples are extracted from open source projects. 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
@Override
@WebApiDescription(title = "Create download", description = "Create a download node whose content will be a zip which is being created asynchronously.", successStatus = HttpServletResponse.SC_ACCEPTED)
@WebApiParam(name = "entity", title = "Download request", description = "Download request which contains the node ids for the zip elements.", 
             kind = ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple = false)
public List<Download> create(List<Download> entity, Parameters parameters)
{
    Download downloadNode = downloads.createDownloadNode(entity.get(0));
    return Collections.singletonList(downloadNode);
}
 
Example 2
@Operation("request-password-reset")
@WebApiDescription(title = "Request Password Reset", description = "Request password reset",
                   successStatus = HttpServletResponse.SC_ACCEPTED)
@WebApiNoAuth
public void requestPasswordReset(String personId, Client client, Parameters parameters, WithResponse withResponse)
{
    people.requestPasswordReset(personId, client.getClient());
}
 
Example 3
@Operation("reset-password")
@WebApiDescription(title = "Reset Password", description = "Performs password reset", successStatus = HttpServletResponse.SC_ACCEPTED)
@WebApiNoAuth
public void resetPassword(String personId, PasswordReset passwordReset, Parameters parameters, WithResponse withResponse)
{
    people.resetPassword(personId, passwordReset);
}
 
Example 4
@Test
public void prepareFrameworkRepresentationReturnsCorrectStatusCode() {

    int expectedCode = HttpServletResponse.SC_ACCEPTED;
    Response.ResponseBuilder actualResponse = handler.prepareFrameworkRepresentation(null, expectedCode, null, null, null);
    assertThat(actualResponse.build().getStatus()).isEqualTo(expectedCode);
}
 
Example 5
@Test
public void prepareFrameworkRepresentationReturnsCorrectStatusCode() {

    int expectedCode = HttpServletResponse.SC_ACCEPTED;
    Response.ResponseBuilder actualResponse = handler.prepareFrameworkRepresentation(null, expectedCode, null, null, null);
    assertThat(actualResponse.build().getStatus()).isEqualTo(expectedCode);
}
 
Example 6
Source Project: gocd   File: DownloadAction.java    License: Apache License 2.0 5 votes vote down vote up
private int download(HttpService httpService, String url, FetchHandler handler) throws Exception {
    int returnCode = httpService.download(url, handler);
    while (returnCode == HttpServletResponse.SC_ACCEPTED) {
        clock.sleepForMillis(DOWNLOAD_SLEEP_MILLIS);
        returnCode = httpService.download(url, handler);
    }
    return returnCode;
}
 
Example 7
Source Project: buck   File: ArtifactCacheHandler.java    License: Apache License 2.0 5 votes vote down vote up
private int handlePut(Request baseRequest, HttpServletResponse response) throws IOException {
  Path temp = null;
  try {
    projectFilesystem.mkdirs(projectFilesystem.getBuckPaths().getScratchDir());
    temp =
        projectFilesystem.createTempFile(
            projectFilesystem.getBuckPaths().getScratchDir(), "incoming_upload", ".tmp");

    HttpArtifactCacheBinaryProtocol.StoreResponseReadResult storeRequest;
    try (DataInputStream requestInputData = new DataInputStream(baseRequest.getInputStream());
        OutputStream tempFileOutputStream = projectFilesystem.newFileOutputStream(temp)) {
      storeRequest =
          HttpArtifactCacheBinaryProtocol.readStoreRequest(
              requestInputData, tempFileOutputStream);
    }

    if (!storeRequest.getActualHashCode().equals(storeRequest.getExpectedHashCode())) {
      response.getWriter().write("Checksum mismatch.");
      return HttpServletResponse.SC_NOT_ACCEPTABLE;
    }

    artifactCache
        .get()
        .store(
            ArtifactInfo.builder()
                .setRuleKeys(storeRequest.getRuleKeys())
                .setMetadata(storeRequest.getMetadata())
                .build(),
            BorrowablePath.borrowablePath(temp));
    return HttpServletResponse.SC_ACCEPTED;
  } finally {
    if (temp != null) {
      projectFilesystem.deleteFileAtPathIfExists(temp);
    }
  }
}
 
Example 8
@WebApiDescription(title = "Cancel download", description = "Stop the zip creation if still in progress.", successStatus = HttpServletResponse.SC_ACCEPTED)
@Override
public void delete(String nodeId, Parameters parameters)
{
    downloads.cancel(nodeId);
}