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:com.netflix.spinnaker.gate.controllers.EntityTagsController.java

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.ACCEPTED)
public Map post(@RequestParam("entityId") String entityId, @RequestParam("entityType") String entityType,
        @RequestParam(value = "account") String account, @RequestParam(value = "region") String region,
        @RequestParam(value = "cloudProvider") String cloudProvider,
        @RequestParam(value = "application", required = false) String application,
        @RequestParam(value = "isPartial", defaultValue = "true") Boolean isPartial,
        @RequestBody List<Map> tags) {

    Map<String, String> entityRef = new HashMap<>();
    entityRef.put("entityId", entityId);
    entityRef.put("entityType", entityType);
    entityRef.put("account", account);
    entityRef.put("region", region);
    entityRef.put("cloudProvider", cloudProvider);

    Map<String, Object> job = new HashMap<>();
    job.put("type", "upsertEntityTags");
    job.put("entityRef", entityRef);
    job.put("isPartial", isPartial);
    job.put("tags", tags);

    List<Map<String, Object>> jobs = new ArrayList<>();
    jobs.add(job);/* ww  w.  j  a va2s. co  m*/

    if (application == null) {
        application = Names.parseName(entityId).getApp();
    }

    Map<String, Object> operation = new HashMap<>();
    operation.put("application", application);
    operation.put("description", "Updating Tags on '" + entityId + "'");
    operation.put("job", jobs);
    return taskService.create(operation);
}

From source file:com.phoenixnap.oss.sample.server.controllers.DrinkControllerImpl.java

@Override
public ResponseEntity createDrink(CreateDrinkRequest createDrinkRequest) {
    LOG.debug("Entered createDrink endpoint");
    try {//from   w w w.j a  v a 2s.c  o  m
        DrinkTypeEnum drinkType = DrinkTypeEnum.valueOf(String.valueOf(createDrinkRequest.getType()));
        AbstractDrink drink = null;
        switch (drinkType) {
        case ALCOHOL:
            drink = new AlcoholicDrink(createDrinkRequest.getName());
            break;
        case SOFT_DRINK:
            drink = new SoftDrink(createDrinkRequest.getName());
            break;
        default:
            LOG.error("Incorrect drink type passed: [{}] ", createDrinkRequest.getType());
            return new ResponseEntity(HttpStatus.BAD_REQUEST);
        }
        this.drinksService.addDrink(drink);
        LOG.info("Returning from createDrink");
        return new ResponseEntity(HttpStatus.ACCEPTED);
    } catch (DrinkNotFoundException dex) {
        return new ResponseEntity(HttpStatus.NOT_FOUND);
    }

}

From source file:plbtw.klmpk.barang.hilang.controller.UserController.java

@RequestMapping(method = RequestMethod.GET, produces = "application/json")
public CustomResponseMessage getAllUsers(@RequestHeader String apiKey) {
    try {//from   w w w. j  a va2s . co  m
        if (!authApiKey(apiKey)) {
            return new CustomResponseMessage(HttpStatus.FORBIDDEN, "Please use your api key to authentication");
        }

        if (checkRateLimit(RATE_LIMIT, apiKey)) {
            return new CustomResponseMessage(HttpStatus.BANDWIDTH_LIMIT_EXCEEDED,
                    "Please wait a while, you have reached your rate limit");
        }

        LogRequest temp = DependencyFactory.createLog(apiKey, "Get");

        Log log = new Log();
        log.setApiKey(temp.getApiKey());
        log.setStatus(temp.getStatus());
        log.setTimeRequest(temp.getTime_request());
        logService.addLog(log);

        List<User> allUsers = (List<User>) userService.getAllUsers();
        for (User user : allUsers) {
            Link selfLink = linkTo(UserController.class).withSelfRel();
            user.add(selfLink);
        }
        CustomResponseMessage result = new CustomResponseMessage();
        result.add(linkTo(UserController.class).withSelfRel());
        result.setHttpStatus(HttpStatus.ACCEPTED);
        result.setMessage("Success");
        result.setResult(allUsers);
        return result;
    } catch (Exception ex) {
        return new CustomResponseMessage(HttpStatus.FORBIDDEN, "Please use your api key to authentication");
    }
}

From source file:org.openbaton.nfvo.api.RestVimInstances.java

/**
 * This operation updates the Network Service Descriptor (NSD)
 *
 * @param new_vimInstance the new datacenter to be updated to
 * @param id the id of the old datacenter
 * @return VimInstance the VimInstance updated
 *///  w w  w  . j av  a  2  s  .  c o m
@RequestMapping(value = "{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public VimInstance update(@RequestBody @Valid VimInstance new_vimInstance, @PathVariable("id") String id,
        @RequestHeader(value = "project-id") String projectId)
        throws VimException, PluginException, EntityUnreachableException, IOException {
    return vimManagement.update(new_vimInstance, id, projectId);
}

From source file:com.somerledsolutions.pa11y.client.ApplicationTest.java

@Test
public void shouldCallRunTaskOnClientWithCorrectArguments() throws Exception {

    when(optionsValidator.validateRunOptions(any(CommandLine.class))).thenReturn(true);
    when(client.runTask("someId", "http://0.0.0.0:3000")).thenReturn(HttpStatus.ACCEPTED);

    testee.run("-r", "-tid", "someId", "-u", "http://0.0.0.0:3000");
    verify(client, times(1)).runTask("someId", "http://0.0.0.0:3000");
}

From source file:com.somerledsolutions.pa11y.client.Pa11yRestClientImplTest.java

@Test
public void testRunTask() throws Exception {

    Map<String, String> params = new HashMap<String, String>();
    params.put("host", "HOST");
    params.put("id", "taskId");

    ResponseEntity<Object> entity = new ResponseEntity<Object>(HttpStatus.ACCEPTED);
    when(restTemplate.postForEntity("{host}/tasks/{id}/run", null, null, params)).thenReturn(entity);

    HttpStatus status = testee.runTask("taskId", "HOST");

    verify(restTemplate, times(1)).postForEntity("{host}/tasks/{id}/run", null, null, params);

    assertSame(entity.getStatusCode(), status);

}

From source file:org.smigo.species.SpeciesController.java

@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/rest/species/{id:\\d+}", method = RequestMethod.PUT)
@ResponseBody/* w  w w  . j a v  a 2 s .  c o m*/
public Object updateSpecies(@Valid @RequestBody Species species, BindingResult result, @PathVariable int id,
        @AuthenticationPrincipal AuthenticatedUser user, HttpServletResponse response, Locale locale) {
    log.info("Updating species. Species:" + species);
    if (result.hasErrors()) {
        response.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value());
        return result.getAllErrors();
    }
    Review review = speciesHandler.updateSpecies(id, species, user);
    if (review == Review.MODERATOR) {
        response.setStatus(HttpStatus.ACCEPTED.value());
    }
    return speciesHandler.getSpecies(id);
}

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

@RequestMapping(value = "/scheduledActions/executions/{id}/cancel", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.ACCEPTED)
public void cancelExecution(@PathVariable String id)
        throws ActionInstanceNotFoundException, ExecutionNotFoundException {
    actionsOperator.cancel(id);//w w  w  .  ja  v a2 s . com
}

From source file:be.solidx.hot.web.deprecated.ScriptExecutorController.java

public ResponseEntity<String> printHotPage(WebRequest webRequest, String page) {
    ResponseEntity<String> responseEntity;
    try {/*from  w w w  .j av a 2s. co  m*/
        page = page + getPageExtension();
        Script<String> pageScript = new Script<String>(IOUtils.toByteArray(loadResource(page)), page);
        byte[] bytes = pageCompiler.compile(pageScript).getBytes("UTF-8");
        Script<COMPILED_SCRIPT> script = buildScript(bytes, page);
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);
        scriptExecutor.execute(script, webRequest, dbMap, printWriter);
        responseEntity = new ResponseEntity<String>(stringWriter.toString(), httpHeaders, HttpStatus.ACCEPTED);
    } catch (Exception e) {
        StringWriter writer = new StringWriter();
        printErrorPage(e, writer);
        responseEntity = new ResponseEntity<String>(writer.toString(), httpHeaders, HttpStatus.ACCEPTED);
    }
    return responseEntity;
}

From source file:org.smigo.species.vernacular.VernacularController.java

@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/rest/vernacular/{id:\\d+}", method = RequestMethod.PUT)
@ResponseBody/* w  w  w .ja  v a  2s. co m*/
public Object updateVernacular(@Valid @RequestBody Vernacular vernacular, BindingResult result,
        @PathVariable int id, @AuthenticationPrincipal AuthenticatedUser user, Locale locale,
        HttpServletResponse response) {
    log.info("Updating vernacular:" + vernacular);
    if (result.hasErrors()) {
        response.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value());
        return result.getAllErrors();
    }
    Review review = vernacularHandler.updateVernacular(id, vernacular, user, locale);
    if (review == Review.MODERATOR) {
        response.setStatus(HttpStatus.ACCEPTED.value());
    }
    return null;
}