Example usage for org.springframework.http HttpStatus CONFLICT

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

Introduction

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

Prototype

HttpStatus CONFLICT

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

Click Source Link

Document

409 Conflict .

Usage

From source file:org.apereo.openlrs.controllers.xapi.XAPIExceptionHandlerAdvice.java

@ExceptionHandler(StatementStateConflictException.class)
@ResponseStatus(value = HttpStatus.CONFLICT)
@ResponseBody/*from w ww  .ja  v  a  2 s .c  o m*/
public XAPIErrorInfo handleStatementStateConflictException(final HttpServletRequest request,
        final HttpServletResponse response, final StatementStateConflictException e) {
    final XAPIErrorInfo result = new XAPIErrorInfo(HttpStatus.CONFLICT, request, e.getLocalizedMessage());
    this.logException(e);
    this.logError(result);
    return result;
}

From source file:de.hska.ld.core.controller.UserControllerIntegrationTest.java

@Test
public void testUpdateUsernameUsesHttpConflictIfAlreadyExists() throws Exception {
    User user = newUser();/*from w  w  w  . ja va 2s. co  m*/

    HttpResponse response = UserSession.admin().post(RESOURCE_USER, user);
    Assert.assertEquals(HttpStatus.CREATED, ResponseHelper.getStatusCode(response));

    HttpResponse response2 = UserSession.admin().post(RESOURCE_USER, user);
    Assert.assertEquals(HttpStatus.CONFLICT, ResponseHelper.getStatusCode(response2));
}

From source file:edu.eci.cosw.restcontrollers.RestControladorRegistrarReserva.java

@RequestMapping(value = "/pagoalquiler", method = RequestMethod.POST)
public ResponseEntity<?> pagarAlquiler(@RequestBody Pago p) {
    HttpStatus status = HttpStatus.NOT_MODIFIED;
    String message = "";
    //logica.realizarPago(p.getIdAlquiler(), p.getMonto(), p.getNumtarjeta(), p.getTipoP());
    if (logica.realizarPago(p.getIdAlquiler(), p.getMonto(), p.getNumtarjeta(), p.getTipoP())) {
        status = HttpStatus.ACCEPTED;//  w  ww  .  jav a2 s. co m
        message = "Solicitud de pago aceptada";
    } else {
        status = HttpStatus.CONFLICT;
        message = "Solicitud de pago rechazada, error de tarjeta o insuficiencia de pago";
    }
    return new ResponseEntity<>(message, status);
}

From source file:edu.eci.cosw.restcontrollers.RestControladorPublicarEstablecimiento.java

/**
 * /*from w  w w. j  a  va2  s.  c  o m*/
 * @param nombre del establecimiento a habilitar
 * @return respuesta a la operacion realizada de habilitacion de establecimiento
 */
@RequestMapping(value = "/inhabilitados/{id}", method = RequestMethod.GET)
public ResponseEntity<?> habilitarEstablecimiento(@PathVariable int id) {
    HttpStatus hs;
    String mens = "";
    try {
        logica.habilitarEstablecimiento(id);
        hs = HttpStatus.CREATED;
    } catch (Exception ex) {
        mens = ex.getMessage();
        hs = HttpStatus.CONFLICT;
    }
    return new ResponseEntity<>(mens, hs);
}

From source file:be.bittich.quote.controller.impl.DefaultExceptionHandler.java

@RequestMapping(produces = APPLICATION_JSON)
@ExceptionHandler(DataIntegrityViolationException.class)
@ResponseStatus(value = HttpStatus.CONFLICT)
public @ResponseBody Map<String, Object> handleDataIntegrityViolationException(
        DataIntegrityViolationException ex) throws IOException {
    Map<String, Object> map = newHashMap();
    map.put("error", "Data Integrity Error");
    map.put("cause", ex.getCause().getLocalizedMessage());
    return map;// w ww .ja v a2 s  . c om
}

From source file:resources.RedSocialColaborativaRESTFUL.java

/**
 *
 * @param _usuario/*from  ww w.  ja  v  a2 s  .  c om*/
 * @return
 */
@RequestMapping(value = "/perfil/acceso", method = RequestMethod.POST, consumes = "application/json")
public ResponseEntity<String> solicitudAcceso(@RequestBody NuevoUsuarioDTO _usuario) {
    if (!_usuario.getMail().equals(_usuario.getConfMail())) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    } else if (!_usuario.getPassword().equals(_usuario.getConfPassword())) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }

    try {
        red.solicitarAcceso(_usuario.getUsername(), _usuario.getMail(), _usuario.getPassword());
    } catch (RuntimeException e) {
        //codigo 409
        return new ResponseEntity<>(HttpStatus.CONFLICT);
    }

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

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

@ExceptionHandler(InUseException.class)
public ResponseEntity<ErrorMessage> handleInUseException(InUseException exception) {
    logger.error("Element In Use Exception", exception);
    return new ResponseEntity<>(new ErrorMessage(exception), HttpStatus.CONFLICT);
}

From source file:com.javiermoreno.springboot.mvc.users.UserCtrl.java

/**
 * Creates a new user with the provided password
 * @param dto An object with a DailyUser and a Password
 * @return 201 Created if ok, 409 Conflict if already exists that username.
 *///from   w  ww.j a v a  2 s. com
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(value = "POST /users", notes = "Returns the created user with its assigned id. 201 if ok, 409 if already exists.")
public HttpEntity<DailyUserResource> createNewUser(@RequestBody UserAndPasswordDTO dto) {
    DailyUserResource resource = new DailyUserResource();
    resource.user = dto.user;
    resource.add(linkTo(methodOn(UserCtrl.class).showUser(dto.user.getEmail())).withSelfRel());
    try {
        userService.registerNewUser(dto.user, dto.password, true);
        return new ResponseEntity<>(resource, HttpStatus.OK);
    } catch (DataIntegrityViolationException exc) {
        return new ResponseEntity<>(resource, HttpStatus.CONFLICT);
    }
}

From source file:org.osiam.resources.exception.OsiamExceptionHandler.java

@ExceptionHandler(UnrecognizedPropertyException.class)
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody/*www  .  j  a  v  a 2 s.  co m*/
public ErrorResponse handleUnrecognizedProperty(UnrecognizedPropertyException e) {
    LOGGER.error("Unknown property", e);
    return produceErrorResponse(e.getMessage(), HttpStatus.CONFLICT, new JsonPropertyMessageTransformer());
}

From source file:com.surevine.alfresco.audit.integration.CreateWikiPageTest.java

/**
 * Test to ensure that when the user attempts to create a wiki page with the same name as another wiki page that the
 * attempt is audited as unsuccessful./*from  w  ww . ja v  a  2 s  .c  o m*/
 */
@Test
public void testDuplicateDocumentCreationAttempt() {

    String pageName = "duplicate";
    String failureDetails = "Request could not be completed due to a conflict with the current state of the resource.";

    try {

        JSONObject request = new JSONObject();

        request.put(AlfrescoJSONKeys.PAGE, "wiki-page");
        request.put(AlfrescoJSONKeys.PAGETITLE, pageName);
        request.put(AlfrescoJSONKeys.PAGE_CONTENT, "<p>duplicate.</p>");

        JSONObject response = new JSONObject();
        JSONObject status = new JSONObject();
        status.put(AlfrescoJSONKeys.CODE, HttpServletResponse.SC_CONFLICT);
        status.put(AlfrescoJSONKeys.NAME, "Conflict");
        status.put(AlfrescoJSONKeys.DESCRIPTION, failureDetails);
        response.put("status", status);

        mockRequest.setRequestURI("/alfresco/s/slingshot/wiki/page/mytestsite/" + pageName);
        mockRequest.setMethod(cut.getMethod());
        mockRequest.setContent(request.toString().getBytes());
        mockResponse = new MockHttpServletResponse();

        mockChain = new ResponseModifiableMockFilterChain(response.toString(), HttpServletResponse.SC_CONFLICT);

        springAuditFilterBean.doFilter(mockRequest, mockResponse, mockChain);

        Auditable audited = getSingleAuditedEvent();

        assertEquals(false, audited.isSuccess());
        assertEquals(HttpStatus.CONFLICT.toString() + ": " + HttpStatus.CONFLICT.name(), audited.getDetails());

    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}