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.nebhale.cyclinglibrary.web.ItemController.java

@RequestMapping(method = RequestMethod.PUT, value = "/{itemId}", consumes = ApplicationMediaType.ITEM_VALUE, produces = ApplicationMediaType.TASK_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
@ResponseBody/*from   w  w  w .  j  av  a 2 s  . c om*/
Task update(@PathVariable Long itemId, @RequestBody ItemInput itemInput) {
    return this.pointParser.parse(itemInput.getPoints(),
            new UpdateCallback(this.itemRepository, itemId, itemInput.getName(), itemInput.getShortName()));
}

From source file:com.envision.envservice.rest.CourseResource.java

@POST
@Path("/feedback/{courseId}")
@Produces(MediaType.APPLICATION_JSON)/*  w  w  w.  j  a v  a 2  s  . c  o m*/
public Response feedback(@PathParam("courseId") int courseId, CourseFeedbackBo feedback)
        throws ServiceException {
    HttpStatus status = HttpStatus.ACCEPTED;
    String response = StringUtils.EMPTY;

    if (checkParam(feedback)) {
        courseService.feedback(courseId, feedback);
    } else {
        status = HttpStatus.BAD_REQUEST;
        response = FailResult.toJson(Code.PARAM_ERROR, "??star");
    }

    return Response.status(status.value()).entity(response).build();
}

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

@ApiOperation(value = "Deletes a subset of tags for the provided tag ID", notes = "multiple tags can be deleted for an entity using a comma as a separator, e.g. /tag1,tag2")
@RequestMapping(value = "/{id}/{tag}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.ACCEPTED)
public Map delete(@PathVariable String id, @PathVariable String tag) {
    List<Map<String, Object>> jobs = new ArrayList<>();
    Map<String, Object> job = new HashMap<>();
    job.put("type", "deleteEntityTags");
    job.put("id", id);
    job.put("tags", tag.split(","));
    jobs.add(job);//from w w w  .  j  a  va2 s. c o m

    Map entityTags = entityTagsService.get(id);
    String entityId = (String) ((Map) entityTags.get("entityRef")).get("entityId");
    String application = Names.parseName(entityId).getApp();

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

From source file:com.abdin.noorsingles.web.AdminController.java

@RequestMapping(value = "/login", method = RequestMethod.POST)
public @ResponseBody ResponseEntity login(HttpServletRequest request, @RequestParam("username") String username,
        @RequestParam("paswd") String password) {

    HttpSession session = request.getSession(true);

    adminService.authenticate(username, password, session);

    if (adminService.isAuthenticated(session)) {
        return new ResponseEntity(HttpStatus.ACCEPTED);
    } else {//from  ww  w .j av a 2s  . c  o m
        return new ResponseEntity(HttpStatus.UNAUTHORIZED);
    }
}

From source file:edu.eci.arsw.pacm.controllers.PacmRESTController.java

@RequestMapping(path = "/{salanum}/atacantes", method = RequestMethod.GET)
public ResponseEntity<?> getAtacantes(@PathVariable(name = "salanum") String salanum) {

    try {//w  w w  .  j av  a  2  s  .c om
        return new ResponseEntity<>(services.getAtacantes(Integer.parseInt(salanum)), HttpStatus.ACCEPTED);
    } catch (ServicesException ex) {
        Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>(ex.getLocalizedMessage(), HttpStatus.NOT_FOUND);
    } catch (NumberFormatException ex) {
        Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>("/{salanum}/ must be an integer value.", HttpStatus.BAD_REQUEST);
    }
}

From source file:com.envision.envservice.rest.UserCasePriseResource.java

@POST
@Path("/cancel/{caseId}")
@Produces(MediaType.APPLICATION_JSON)/*from  www.  j a va2s . c  o  m*/
public Response cancelPrise(@PathParam("caseId") int caseId) throws Exception {
    HttpStatus status = HttpStatus.ACCEPTED;
    String response = StringUtils.EMPTY;

    userCasePriseService.cancelPrise(caseId);

    return Response.status(status.value()).entity(response).build();
}

From source file:com.opensearchserver.hadse.cluster.ClusterCatalog.java

final static HttpEntity<?> add(Collection<String> addresses)
        throws URISyntaxException, JsonGenerationException, JsonMappingException, IOException {
    lock.w.lock();// w  w  w .  jav a  2  s. com
    try {
        for (String addr : addresses)
            if (addressMap.containsKey(addr))
                return new ResponseEntity<String>("The address is already registered: " + addr,
                        HttpStatus.ALREADY_REPORTED);
        NodeItem newNode = new NodeItem(addresses);
        nodes.add(newNode);
        for (String ad : addresses) {
            if (isLocal(ad)) {
                localNode = newNode;
                break;
            }
        }
        JsonUtils.mapper.writeValue(clusterFile, nodes);
        return new ResponseEntity<String>("Node registered", HttpStatus.ACCEPTED);
    } finally {
        lock.w.unlock();
    }
}

From source file:com.sms.server.controller.UserController.java

@RequestMapping(value = "/{username}", method = RequestMethod.PUT, headers = {
        "Content-type=application/json" })
@ResponseBody//from   ww w.  j  a  v a 2 s .  c  o m
public ResponseEntity<String> updateUser(@RequestBody User update, @PathVariable("username") String username) {
    User user = userDao.getUserByUsername(username);

    if (user == null) {
        return new ResponseEntity<String>("Username does not exist.", HttpStatus.BAD_REQUEST);
    }

    if (username.equals("admin")) {
        return new ResponseEntity<String>("You are not authenticated to perform this operation.",
                HttpStatus.FORBIDDEN);
    }

    // Update user details
    if (update.getUsername() != null) {
        // Check username is available
        if (userDao.getUserByUsername(user.getUsername()) != null) {
            return new ResponseEntity<String>("Username already exists.", HttpStatus.NOT_ACCEPTABLE);
        } else {
            user.setUsername(update.getUsername());
        }
    }

    if (update.getPassword() != null) {
        user.setPassword(update.getPassword());
    }

    if (update.getEnabled() != null) {
        user.setEnabled(update.getEnabled());
    }

    // Update database
    if (!userDao.updateUser(user, username)) {
        LogService.getInstance().addLogEntry(LogService.Level.ERROR, CLASS_NAME,
                "Error updating user '" + user.getUsername() + "'.", null);
        return new ResponseEntity<String>("Error updating user details.", HttpStatus.INTERNAL_SERVER_ERROR);
    }

    LogService.getInstance().addLogEntry(LogService.Level.INFO, CLASS_NAME,
            "User '" + user.getUsername() + "' updated successfully.", null);
    return new ResponseEntity<String>("User details updated successfully.", HttpStatus.ACCEPTED);
}

From source file:technology.tikal.customers.service.ContactService.java

@RequestMapping(value = "/{contactId}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void deleteContact(@PathVariable final Long customerId, @PathVariable final Long contactId) {
    customersController.deactivateContact(customerId, contactId);
}

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

@PUT
@Path("{id}/start")
@Consumes(MediaType.APPLICATION_JSON)/*from  w w w . j  a  v  a 2 s  . c om*/
public Response startMasterAgreement(@Context UriInfo uriInfo, @PathParam("id") String agreementId) {

    logger.debug("Starting Master Agreement {}", agreementId);

    IAgreement master = agreementDAO.getByAgreementId(agreementId);
    if (master == null) {
        return buildResponse(HttpStatus.NOT_FOUND, "Agreement " + agreementId + " not found");
    }
    List<IAgreement> agreements = agreementDAO.getByMasterId(agreementId);
    agreements.add(master);

    String slaUrl = getSlaUrl(this.slaUrl, uriInfo);
    /* TODO: read supplied Monitoring Platform url from body of request */
    String metricsUrl = getMetricsBaseUrl("", this.monitoringManagerUrl);
    ViolationSubscriber subscriber = getSubscriber(slaUrl, metricsUrl);
    for (IAgreement agreement : agreements) {
        subscriber.subscribeObserver(agreement);
        enforcementService.startEnforcement(agreement.getAgreementId());
    }

    return buildResponse(HttpStatus.ACCEPTED, "Agreement started");
}