Example usage for org.springframework.http HttpStatus ACCEPTED

List of usage examples for org.springframework.http HttpStatus ACCEPTED

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus ACCEPTED.

Prototype

HttpStatus ACCEPTED

To view the source code for org.springframework.http HttpStatus ACCEPTED.

Click Source Link

Document

202 Accepted .

Usage

From source file:me.j360.trace.server.ZipkinHttpCollector.java

@RequestMapping(value = "/api/v1/spans", method = POST)
@ResponseStatus(HttpStatus.ACCEPTED)
public DeferredResult<ResponseEntity<?>> uploadSpansJson(
        @RequestHeader(value = "Content-Encoding", required = false) String encoding,
        @RequestBody byte[] body) {
    return validateAndStoreSpans(encoding, Codec.JSON, body);
}

From source file:application.controllers.RestController.java

@RequestMapping(value = "/transfer", method = RequestMethod.POST)
public ResponseEntity<?> newTransfer(@RequestBody Transfer transfer) {
    Account sender = myBatisService.getByName(transfer.getSender());
    Account reciever = myBatisService.getByName(transfer.getReciever());
    if (reciever == null || sender == null || transfer.getAmount() <= 0
            || sender.getBalance() < transfer.getAmount()) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }// ww w. j a va2  s  .  com
    myBatisService.transferFunds(sender, reciever, transfer);
    return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

From source file:edu.eci.arsw.blindway.controller.GameController.java

@RequestMapping(path = "/maze/{id}/{x}/{y}/car", method = RequestMethod.GET)
public ResponseEntity<?> getCar(@PathVariable Integer id, @PathVariable Integer x, @PathVariable Integer y)
        throws BlindWayException {
    Game g = game.getGame(id);//from ww  w  .j av a  2  s  . c  o m
    return new ResponseEntity<>(g.getCar(), HttpStatus.ACCEPTED);
}

From source file:org.zalando.riptide.BufferingClientHttpResponseTest.java

@Test
public void redirectsStatusFields() throws IOException {
    when(response.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
    when(response.getStatusText()).thenReturn("status-text");
    when(response.getRawStatusCode()).thenReturn(42);
    when(response.getHeaders()).thenReturn(new HttpHeaders());

    unit = buffer(response);//from  ww w .  ja  v a2s . c  o m

    assertThat(unit.getStatusCode(), is(response.getStatusCode()));
    assertThat(unit.getStatusText(), is(response.getStatusText()));
    assertThat(unit.getRawStatusCode(), is(response.getRawStatusCode()));
    assertThat(unit.getHeaders(), is(response.getHeaders()));
}

From source file:com.netflix.scheduledactions.web.controllers.ActionInstanceController.java

@RequestMapping(value = "/scheduledActions/{id}/enable", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.ACCEPTED)
public ActionInstance enableActionInstance(@PathVariable String id) throws ActionInstanceNotFoundException {
    return actionsOperator.enableActionInstance(id);
}

From source file:py.com.sodep.web.UserWatchListController.java

@RequestMapping(value = "/users/{username}/watchlist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addToWatchList(@PathVariable String username,
        @RequestBody String movieTitle) {
    userService.addToWatchList(username, movieTitle);
    return new ResponseEntity<>(new RestResponse(true, "Movie added succesfully"), HttpStatus.ACCEPTED);
}

From source file:com.github.djabry.platform.rest.AuthenticationController.java

/**
 * @param request The request containing the user credentials and details
 * @return A security token on success, null otherwise
 *//* w  w w  .ja v a  2  s. c o m*/
@Override
@ResponseStatus(HttpStatus.ACCEPTED)
@ResponseBody
@RequestMapping(name = "/signup", method = RequestMethod.POST)
public SecurityToken signUp(@NotNull SignUpRequest request) {
    return this.authenticationService.signUp(request);
}

From source file:eu.modaclouds.sla.service.rest.MetricsReceiverRest.java

@POST
@Path("/{agreementId}")
@Produces(MediaType.TEXT_PLAIN)/*from w  w w  .  j  av  a2s.c  om*/
public Response receiveModacloudsMetrics(@PathParam("agreementId") String agreementId, final String metrics) {

    logger.debug("receiveMetrics(agreementId=" + agreementId + ", data=" + metrics.toString());
    IAgreement agreement = agreementDao.getByAgreementId(agreementId);
    logger.debug("agreement=" + agreement.getAgreementId());

    Map<IGuaranteeTerm, List<IMonitoringMetric>> metricsMap = translator.translate(agreement, metrics);
    enforcementService.doEnforcement(agreement, metricsMap);
    return buildResponse(HttpStatus.ACCEPTED, "Metrics received");
}

From source file:com.marklogic.mgmt.admin.AdminManager.java

public void init(String licenseKey, String licensee) {
    final URI uri = adminConfig.buildUri("/admin/v1/init");

    String json = null;/*  w  w  w .  j av a  2  s.  com*/
    if (licenseKey != null && licensee != null) {
        json = format("{\"license-key\":\"%s\", \"licensee\":\"%s\"}", licenseKey, licensee);
    } else {
        json = "{}";
    }
    final String payload = json;

    logger.info("Initializing MarkLogic at: " + uri);
    invokeActionRequiringRestart(new ActionRequiringRestart() {
        @Override
        public boolean execute() {
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON);
            HttpEntity<String> entity = new HttpEntity<String>(payload, headers);
            try {
                ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.POST, entity,
                        String.class);
                logger.info("Initialization response: " + response);
                // According to http://docs.marklogic.com/REST/POST/admin/v1/init, a 202 is sent back in the event a
                // restart is needed. A 400 or 401 will be thrown as an error by RestTemplate.
                return HttpStatus.ACCEPTED.equals(response.getStatusCode());
            } catch (HttpClientErrorException hcee) {
                String body = hcee.getResponseBodyAsString();
                if (logger.isTraceEnabled()) {
                    logger.trace("Response body: " + body);
                }
                if (body != null && body.contains("MANAGE-ALREADYINIT")) {
                    logger.info("MarkLogic has already been initialized");
                    return false;
                } else {
                    logger.error("Caught error, response body: " + body);
                    throw hcee;
                }
            }
        }
    });
}

From source file:com.netflix.spinnaker.gate.controllers.PipelineTemplatesController.java

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.ACCEPTED)
public Map create(@RequestBody Map<String, Object> pipelineTemplate) {
    List<Map<String, Object>> jobs = new ArrayList<>();
    Map<String, Object> job = new HashMap<>();
    job.put("type", "createPipelineTemplate");
    job.put("pipelineTemplate", pipelineTemplate);
    jobs.add(job);//ww  w . j a  v  a2s . c  om

    Map<String, Object> operation = new HashMap<>();
    operation.put("description", "Create pipeline template");
    operation.put("application", getApplicationFromTemplate(pipelineTemplate));
    operation.put("job", jobs);

    return taskService.create(operation);
}