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.trustedanalytics.user.common.TestUtils.java

public static HttpClientErrorException createDummyHttpClientException(UUID userId) {
    String body = "{\"message\":\"Username already in use: test@example.com\",\"error\":\"scim_resource_already_exists\",\"verified\":false,\"active\":true,\"user_id\":\""
            + userId + "\"}";
    HttpClientErrorException exception = new HttpClientErrorException(HttpStatus.CONFLICT, "Conflict",
            body.getBytes(), Charset.defaultCharset());
    return exception;
}

From source file:org.cloudfoundry.identity.uaa.scim.exception.ScimResourceAlreadyExistsException.java

/**
 * @param message a message for the caller
 */
public ScimResourceAlreadyExistsException(String message) {
    super(message, HttpStatus.CONFLICT);
}

From source file:org.cloudfoundry.identity.uaa.scim.exception.ScimResourceConflictException.java

/**
 * @param message a message for the caller
 */
public ScimResourceConflictException(String message) {
    super(message, HttpStatus.CONFLICT);
}

From source file:io.ignitr.dispatchr.manager.core.error.ClientAlreadyRegisteredException.java

/**
 *
 * @param client//from   w ww . j a va2 s .com
 */
public ClientAlreadyRegisteredException(String client) {
    super(HttpStatus.CONFLICT, String.format("Client '%s' is already registered", client),
            ErrorCode.CLIENT_ALREADY_REGISTERED);
}

From source file:io.ignitr.dispatchr.manager.core.error.TopicAlreadyRegisteredException.java

/**
 * Initializes this instance of {@link TopicNotFoundException}.
 *
 * @param topicName name of the topic/*  w  w  w . jav  a 2s.  com*/
 */
public TopicAlreadyRegisteredException(String topicName) {
    super(HttpStatus.CONFLICT, String.format("SNS topic '%s' is already registered", topicName),
            ErrorCode.TOPIC_ALREADY_REGISTERED);
}

From source file:de.hska.ld.core.exception.AlreadyExistsException.java

public AlreadyExistsException(String field) {
    super(field, "ALREADY_EXISTS");
    httpStatus = HttpStatus.CONFLICT;
}

From source file:application.controllers.RestController.java

@RequestMapping(value = "/signup", method = RequestMethod.PUT)
public ResponseEntity<?> newAccount(@RequestBody String account) {
    if (myBatisService.getByName(account) != null) {
        return new ResponseEntity<>(HttpStatus.CONFLICT);
    } else {//from w w w . j ava 2  s  . com
        Account newAccount = new Account();
        newAccount.setName(account);
        newAccount.setBalance(1000);
        myBatisService.insertAccount(newAccount);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:io.pivotal.ecosystem.service.HelloController.java

@RequestMapping(value = "/users", method = RequestMethod.POST)
ResponseEntity<User> createUser(@RequestBody User user) {
    if (userStore.userExists(user.getName())) {
        return new ResponseEntity<>(HttpStatus.CONFLICT);
    }/*  w ww  .j  a v a2 s  .  c o  m*/
    setPassword(user);
    userStore.save(user);
    return new ResponseEntity<>(user, HttpStatus.CREATED);
}

From source file:gt.dakaik.exceptions.ManejadorExcepciones.java

@ResponseBody
@ExceptionHandler(EntidadDuplicadaException.class)
@ResponseStatus(HttpStatus.CONFLICT)
Map<String, String> entidadDuplicadaExceptionHandler(EntidadDuplicadaException ex) {
    Map<String, String> res = new HashMap<>();
    res.put("error", "Entidad duplicada");
    res.put("entidad", ex.getMessage());
    return res;/*from   w  ww.  j a  v a  2s  . c o  m*/
}

From source file:eu.tripledframework.demo.presentation.GlobalExceptionControllerAdvice.java

@ExceptionHandler
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody/*w  w  w .j  a  v  a2  s.  c  o m*/
public List<ErrorMessage> handleExecutionException(ExecutionException exception) throws Throwable {
    // we simply rethrow the cause.
    List<ErrorMessage> errorMessages = new ArrayList<>();
    if (exception.getCause() instanceof CommandValidationException) {
        errorMessages.addAll(handleValidationError((CommandValidationException) exception.getCause()));
    } else {
        LOGGER.error("The execution failed with an uncaught exception.", exception);
        errorMessages.add(new ErrorMessage("The execution failed with an uncaught exception."));
    }
    return errorMessages;
}