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:org.coursera.cmbrehm.kewlvideo.server.VideoController.java

@RequestMapping(value = "/video/{id}/data", method = RequestMethod.POST)
public ResponseEntity<VideoStatus> saveVideoData(@PathVariable("id") long id,
        @RequestPart("data") MultipartFile videoData) {
    ResponseEntity<VideoStatus> response;
    try {/*  ww  w . j  av a  2 s.  com*/
        InputStream videoDataStream = videoData.getInputStream();
        VideoFileManager vfmgr = VideoFileManager.get();
        Video video = videoList.get(id);
        if (video != null) {
            vfmgr.saveVideoData(video, videoDataStream);
            response = new ResponseEntity<VideoStatus>(new VideoStatus(VideoState.READY), HttpStatus.ACCEPTED);
        } else {
            response = new ResponseEntity<VideoStatus>(HttpStatus.NOT_FOUND);
        }
    } catch (IOException iox) {
        response = new ResponseEntity<VideoStatus>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return response;
}

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

@RequestMapping(value = "/find/{id}", method = RequestMethod.GET, produces = "application/json")
public CustomResponseMessage getUser(@RequestHeader String apiKey, @PathVariable("id") long id) {
    try {// w ww.jav a 2  s.c o 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);

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

From source file:it.reply.orchestrator.controller.DeploymentController.java

/**
 * Update the deployment.// ww  w.  ja v  a 2 s.  c om
 * 
 * @param id
 *          the deployment id
 * @param request
 *          {@link DeploymentRequest}
 */
@ResponseStatus(HttpStatus.ACCEPTED)
@RequestMapping(value = "/deployments/{deploymentId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public void updateDeployment(@PathVariable("deploymentId") String id,
        @Valid @RequestBody DeploymentRequest request) {

    deploymentService.updateDeployment(id, request);
}

From source file:org.createnet.raptor.auth.service.controller.RoleController.java

@PreAuthorize("hasAuthority('admin') or hasAuthority('super_admin')")
@RequestMapping(value = { "/role/{roleId}" }, method = RequestMethod.DELETE)
@ApiOperation(value = "Delete a role", notes = "", code = 202, nickname = "deleteRole")
public ResponseEntity<Role> delete(
        @AuthenticationPrincipal RaptorUserDetailsService.RaptorUserDetails currentUser,
        @PathVariable Long roleId) {

    if (!roleService.delete(roleId)) {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
    }//from  ww w .ja v a 2  s .c om

    logger.debug("Deleted role {}", roleId);
    return ResponseEntity.status(HttpStatus.ACCEPTED).body(null);
}

From source file:at.ac.tuwien.infosys.ArtifactBuilder.java

@RequestMapping(value = "/build", method = RequestMethod.POST)
public ResponseEntity<String> build(@RequestBody DeviceUpdateRequest updateRequest) {

    logger.info("Got request: " + updateRequest);

    if (updateRequest == null)
        return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);

    updateRequest.setVersion(updateRequest.getVersion().replace(".", "_"));

    ResponseEntity<Component[]> dmsResponse = restTemplate.getForEntity(dmsURL, Component[].class,
            updateRequest.getComponent(), updateRequest.getVersion());

    logger.info("Invoked Component/Dependency-Management and received: " + dmsResponse.getStatusCode());

    if (dmsResponse.getStatusCode() != HttpStatus.OK)
        return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);

    Plan bundle = new Plan(dmsResponse.getBody());

    logger.info("Received following bundle: " + bundle);

    try {//from  w w  w.  ja  v a2 s  . co  m
        String idPrefix = updateRequest.getComponent() + "_" + updateRequest.getVersion();

        // search if an image for the respective component and version
        // already exists
        Image image = imageStorage.getUpdate(idPrefix);

        if (image == null) {
            Path imagePath = imageUtil.createImage(bundle, idPrefix);

            // Upload image to image store
            image = imageStorage.storeUpdate(updateRequest.getDeviceIds(), imageUtil.getImageId(),
                    Files.newInputStream(imagePath));

            logger.info("Finished uploading image to image-store");
        } else {
            logger.info("Image already present in image-store, reuse it!");
            if (image.getDeviceIds() == null)
                image.setDeviceIds(updateRequest.getDeviceIds());
        }

        // Invoke device manager to send image
        //
        //         Map<String, Object> map = new HashMap<String, Object>();
        //         map.put("force", updateRequest.isPush());

        ResponseEntity<String> managerResponse = restTemplate.postForEntity(managerURL, image, String.class);

        logger.info("Received request from device-manager: " + managerResponse.getStatusCode());

    } catch (IOException e) {
        e.printStackTrace();
        return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
    } finally {
        if (imageUtil != null)
            try {
                imageUtil.clean();
            } catch (Exception e) {
            }
    }

    return new ResponseEntity<String>(HttpStatus.ACCEPTED);
}

From source file:org.createnet.raptor.auth.service.controller.DeviceController.java

@RequestMapping(value = "/sync", method = RequestMethod.POST)
@ApiOperation(value = "Sync user permission on a device", notes = "", code = 202, nickname = "syncPermission")
public ResponseEntity<?> syncPermission(
        @AuthenticationPrincipal RaptorUserDetailsService.RaptorUserDetails currentUser,
        @RequestBody SyncRequest body) {

    deviceService.sync(currentUser, body);
    return ResponseEntity.status(HttpStatus.ACCEPTED).body(null);
}

From source file:org.openbaton.nfvo.vnfm_reg.impl.receiver.VnfmReceiverRest.java

@RequestMapping(value = "vnfm-core-allocate", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public NFVMessage allocate(@RequestBody VnfmOrAllocateResourcesMessage message) throws VimException {

    try {/*from w  w w . j av a2  s .c  o m*/
        return mapper.fromJson(vnfmManager.executeAction(message), OrVnfmGenericMessage.class);
    } catch (ExecutionException e1) {
        e1.printStackTrace();
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    return null;
}

From source file:org.nekorp.workflow.backend.controller.imp.ServicioControllerImp.java

@Override
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void borrarServicio(@PathVariable final Long id, final HttpServletResponse response) {
    Servicio dato = this.servicioDAO.consultar(id);
    if (dato == null) {
        //no hay nada que responder
        response.setStatus(HttpStatus.NO_CONTENT.value());
        return;//from  ww  w .ja v a2 s  .  c o  m
    }
    //hay que borrar costos y bitacora primero
    this.saveBitacora(id, new LinkedList<Evento>(), response);
    this.saveCosto(id, new LinkedList<RegistroCosto>(), response);
    //se borra servicio y listo
    servicioDAO.borrar(dato);
    //se acepto la peticion de borrado, no quiere decir que sucede de inmediato.
    response.setStatus(HttpStatus.ACCEPTED.value());
}

From source file:org.nekorp.workflow.backend.controller.imp.ClienteControllerImp.java

@Override
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void borrarCliente(@PathVariable final Long id, final HttpServletResponse response) {
    Cliente respuesta = this.clienteDao.consultar(id);
    if (respuesta == null) {
        //no hay nada que responder
        response.setStatus(HttpStatus.NO_CONTENT.value());
        return;/*from   w  w w . java  2s  . co  m*/
    }
    clienteDao.borrar(respuesta);
    //se acepto la peticion de borrado, no quiere decir que sucede de inmediato.
    response.setStatus(HttpStatus.ACCEPTED.value());
}

From source file:org.bonitasoft.web.designer.controller.ResourceControllerAdvice.java

@ExceptionHandler(MalformedJsonException.class)
public ResponseEntity<ErrorMessage> handleJsonProcessingException(MalformedJsonException exception) {
    logger.error("Error while uploading a json file " + exception.getMessage());
    // BS-14113: HttpStatus.ACCEPTED internet explorer don't recognize response if sent with http error code
    ErrorMessage message = new ErrorMessage(exception);
    message.addInfo("location", exception.getLocationInfos());
    return new ResponseEntity<>(message, HttpStatus.ACCEPTED);
}