Example usage for org.springframework.http HttpStatus NO_CONTENT

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

Introduction

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

Prototype

HttpStatus NO_CONTENT

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

Click Source Link

Document

204 No Content .

Usage

From source file:com.gazbert.bxbot.rest.api.StrategyConfigController.java

/**
 * Deletes a Strategy configuration for a given id.
 *
 * @param user the authenticated user./*from   w  ww  . j a v a  2  s. c o  m*/
 * @param strategyId the id of the Strategy configuration to delete.
 * @return 204 'No Content' HTTP status code if update successful, 404 'Not Found' HTTP status code if Strategy config not found.
 */
@RequestMapping(value = "/strategy/{strategyId}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteStrategy(@AuthenticationPrincipal User user, @PathVariable String strategyId) {

    final StrategyConfig deletedConfig = strategyConfigService.deleteStrategyById(strategyId);
    return deletedConfig.getId() != null ? new ResponseEntity<>(HttpStatus.NO_CONTENT)
            : new ResponseEntity<>(HttpStatus.NOT_FOUND);

}

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

/**
 * This operation is used to remove a disabled Network Service Descriptor
 *
 * @param id : the id of Network Service Descriptor
 */// www.  j av a2 s. c  om
@RequestMapping(value = "{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId)
        throws VimException, InterruptedException, ExecutionException, NotFoundException {
    try {
        networkServiceRecordManagement.delete(id, projectId);
    } catch (WrongStatusException e) {
        e.printStackTrace();
        throw new StateException(id);
    }
}

From source file:com.consol.citrus.demo.javaland.EmployeeResourceTest.java

@Test
@InSequence(6)/*from   w w w.j ava2  s  .c o  m*/
@CitrusTest
public void testDeleteAll(@CitrusResource TestDesigner citrus) {
    citrus.http().client(serviceUri).delete();

    citrus.http().client(serviceUri).response(HttpStatus.NO_CONTENT);

    citrus.http().client(serviceUri).get().accept(MediaType.APPLICATION_XML);

    citrus.http().client(serviceUri).response(HttpStatus.OK).payload("<employees></employees>");

    citrusFramework.run(citrus.getTestCase());
}

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

/**
 * Delete the deployment.//  ww w. j ava 2  s .  c  om
 * 
 * @param id
 *          the deployment id
 */
@ResponseStatus(HttpStatus.NO_CONTENT)
@RequestMapping(value = "/deployments/{deploymentId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public void deleteDeployment(@PathVariable("deploymentId") String id) {

    deploymentService.deleteDeployment(id);
}

From source file:com.auditbucket.engine.endpoint.TrackEP.java

@ResponseBody
@RequestMapping(value = "/log/", consumes = "application/json", produces = "application/json", method = RequestMethod.POST)
public ResponseEntity<LogResultBean> trackLog(@RequestBody LogInputBean input, String apiKey,
        @RequestHeader(value = "Api-Key", required = false) String apiHeaderKey) throws DatagioException {

    // If we have a valid company we are good to go.
    Company company = getCompany(apiHeaderKey, apiKey);

    LogResultBean resultBean = mediationFacade.processLogForCompany(company, input);
    LogInputBean.LogStatus ls = resultBean.getStatus();
    if (ls.equals(LogInputBean.LogStatus.FORBIDDEN))
        return new ResponseEntity<>(resultBean, HttpStatus.FORBIDDEN);
    else if (ls.equals(LogInputBean.LogStatus.NOT_FOUND)) {
        input.setAbMessage("Illegal meta key");
        return new ResponseEntity<>(resultBean, HttpStatus.NOT_FOUND);
    } else if (ls.equals(LogInputBean.LogStatus.IGNORE)) {
        input.setAbMessage("Ignoring request to change as the 'what' has not changed");
        return new ResponseEntity<>(resultBean, HttpStatus.NOT_MODIFIED);
    } else if (ls.equals(LogInputBean.LogStatus.ILLEGAL_ARGUMENT)) {
        return new ResponseEntity<>(resultBean, HttpStatus.NO_CONTENT);
    }/*from   w  w w.java2  s .com*/

    return new ResponseEntity<>(resultBean, HttpStatus.OK);
}

From source file:org.bozzo.ipplan.web.InfrastructureController.java

@ApiResponses({ @ApiResponse(code = 204, message = "No Content") })
@RequestMapping(value = "/{infraId}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteInfrastructure(@PathVariable Integer infraId) {
    logger.info("delete infrastruture with id: {}", infraId);
    repository.delete(infraId);/*from w ww  .j a  v  a  2 s. c  om*/
}

From source file:cn.org.once.cstack.volumes.VolumeControllerTestIT.java

/**
* Cannot create two volumes with same name
*
* @throws Exception//from w  ww.  j  a va  2  s . co m
*/
@Test()
public void createTwoVolumesWithError() throws Exception {
    VolumeResource volumeResource = new VolumeResource();

    volumeResource.setName("shared" + new Random().nextInt(100000));
    ResultActions resultActions = createVolume(volumeResource);
    resultActions.andExpect(status().isCreated());
    // Convert the result to pojo
    volumeResource = getVolumeResource(mapper, resultActions);

    // Try to create a second volume but error
    resultActions = createVolume(volumeResource);
    resultActions.andExpect(status().is4xxClientError());

    // delete the volume
    deleteVolume(volumeResource.getId(), HttpStatus.NO_CONTENT);
}

From source file:com.largecode.interview.rustem.controller.UsersController.java

@PreAuthorize("@userRightResolverServiceImpl.canAccessToUser(principal, #id)")
@ApiOperation(value = "Update User.", notes = "Returns NO_CONTENT if update was successful. Regular user can not change his Role.")
@ApiResponses(value = { @ApiResponse(code = 401, message = "Only authenticated access allowed."),
        @ApiResponse(code = 403, message = "Only user of ADMIN role or User has authenticated with this Id can have access."),
        @ApiResponse(code = 404, message = "User with such Id not found."),
        @ApiResponse(code = 400, message = "Reasons:\n" + "1:Passwords not same or too short.\n"
                + "2:Other userDto.email already exists.\n" + "3:Bad role name.\n"
                + "3:value of ID different between Id in URL and userDto \n") })
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateUser(@ApiParam(value = "ID of User from DB", required = true) @PathVariable Long id,
        @ApiParam(value = "new properties for User by userDto", required = true) @Valid @RequestBody UserDto userDto,
        @ApiParam(value = "Authentication", hidden = true) Authentication authentication) {
    SpringUser springUser = (SpringUser) authentication.getPrincipal();
    LOGGER.debug("Update user {} by user '{}'", userDto, springUser.getUsername());
    checkUrlAndBodyForId(id, userDto);//from   ww w  .j  a va 2  s.  co m
    checkEmailNotExists(userDto, "update user");
    try {
        usersService.updateUser(id, userDto, springUser.getRole());
    } catch (NoSuchElementException exception) {
        throw new ExceptionUserNotFound(exception.getMessage());
    }
}

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

@Override
@RequestMapping(value = "/{idEvento}", method = RequestMethod.DELETE)
public void borrarEvento(@PathVariable final Long idServicio, @PathVariable final Long idEvento,
        final HttpServletResponse response) {
    if (!idServicioValido(idServicio)) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return;// w ww. j ava2  s.c  om
    }
    Evento dato = eventoDAO.consultar(idServicio, idEvento);
    if (dato == null) {
        //no hay nada que responder
        response.setStatus(HttpStatus.NO_CONTENT.value());
        return;
    }
    eventoDAO.borrar(idServicio, dato);
    //se acepto la peticion de borrado, no quiere decir que sucede de inmediato.
    response.setStatus(HttpStatus.ACCEPTED.value());
}

From source file:com.consol.citrus.samples.javaee.employee.EmployeeResourceTest.java

@Test
@InSequence(6)/*from w w  w  .  jav a  2  s.  c  om*/
@CitrusTest
public void testDeleteAll(@CitrusResource TestDesigner citrus) {
    citrus.http().client(serviceUri).send().delete();

    citrus.http().client(serviceUri).receive().response(HttpStatus.NO_CONTENT);

    citrus.http().client(serviceUri).send().get().accept(MediaType.APPLICATION_XML);

    citrus.http().client(serviceUri).receive().response(HttpStatus.OK).payload("<employees></employees>");

    citrusFramework.run(citrus.getTestCase());
}