List of usage examples for org.springframework.http HttpStatus CONFLICT
HttpStatus CONFLICT
To view the source code for org.springframework.http HttpStatus CONFLICT.
Click Source Link
From source file:org.swarmcom.jsynapse.controller.client.api.v1.AuthenticationRestApiTest.java
@Test public void testRegisterAndLoginPassword() throws Exception { // login with user not registered postAndCheckStatus("/_matrix/client/api/v1/login", postLoginRequest, HttpStatus.NOT_FOUND); // register// www .ja v a 2 s.c o m postAndCompareResult("/_matrix/client/api/v1/register", postLoginRequest, postLoginResponse); // login postAndCompareResult("/_matrix/client/api/v1/login", postLoginRequest, postLoginResponse); // register with an existing user postAndCheckStatus("/_matrix/client/api/v1/register", postLoginRequest, HttpStatus.CONFLICT); }
From source file:cz.muni.fi.editor.webapp.controllers.ajax.AjaxNotificationController.java
@RequestMapping("/auth/ajax/notification/mark/") public ResponseEntity<String> mark(MarkSeenNotificationRequest markSeenNotificationRequest) { try {//from w w w. jav a 2 s. com notificationService.markSeen(markSeenNotificationRequest.getValues().stream().map(this::notification) .collect(Collectors.toList())); return new ResponseEntity<>("SUCCESS", HttpStatus.OK); } catch (FieldException e) { log.warn(e); return new ResponseEntity<>(e.getMessage(), HttpStatus.CONFLICT); } }
From source file:ch.wisv.areafiftylan.exception.GlobalControllerExceptionHandler.java
@ExceptionHandler(TicketAlreadyLinkedException.class) public ResponseEntity<?> handleInvalidRFIDException(TicketAlreadyLinkedException e) { return createResponseEntity(HttpStatus.CONFLICT, e.getMessage()); }
From source file:cz.muni.fi.editor.webapp.controllers.ajax.AjaxOrganizationController.java
@RequestMapping(value = "/kick/") public ResponseEntity<String> kick(@RequestParam Long organization, @RequestParam Long user) { OrganizationDTO org = new OrganizationDTO(); org.setId(organization);/*from www . j a v a 2s. com*/ UserDTO userDTO = new UserDTO(); userDTO.setId(user); try { organizationService.kick(org, userDTO); return OK; } catch (FieldException ex) { log.warn(ex); return new ResponseEntity<>(ex.getMessage(), HttpStatus.CONFLICT); } }
From source file:org.jrb.docasm.web.GlobalExceptionHandler.java
/** * Converts one of several client-based conflict exceptions into an HTTP 409 * response with an error body. The mapped exceptions are as follows: * <ul>//from w ww .ja v a2 s. c o m * <li>{@link DuplicateDocumentException}</li> * </ul> * * @param e * the client exception * @return the error body */ @ExceptionHandler({ DuplicateDocumentException.class }) public ResponseEntity<MessageResponse> handleConflictError(final Exception e) { if (LOG.isDebugEnabled()) { LOG.debug(e.getMessage(), e); } return utils.createMessageResponse(e.getMessage(), HttpStatus.CONFLICT); }
From source file:org.createnet.raptor.auth.service.controller.RoleController.java
@PreAuthorize("hasAuthority('admin') or hasAuthority('super_admin')") @RequestMapping(value = { "/role/{roleId}" }, method = RequestMethod.PUT) @ApiOperation(value = "Update a role", notes = "", response = Role.class, nickname = "updateRole") public ResponseEntity<?> update(@AuthenticationPrincipal RaptorUserDetailsService.RaptorUserDetails currentUser, @PathVariable Long roleId, @RequestBody Role rawRole) { if ((rawRole.getName().isEmpty() || rawRole.getName() == null)) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Name property is missing"); }/* w w w .j a va 2 s.co m*/ Role role2 = roleService.getByName(rawRole.getName()); if (role2 != null) { return ResponseEntity.status(HttpStatus.CONFLICT).body(null); } rawRole.setId(roleId); Role role = roleService.update(roleId, rawRole); if (role == null) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); } logger.debug("Updated role {}", role.getName()); return ResponseEntity.ok(role); }
From source file:ca.qhrtech.controllers.TableController.java
@RequestMapping(value = "/table", method = RequestMethod.POST) public ResponseEntity<BGLTable> createTable(@RequestBody BGLTable table) { if (!tableService.doesTableExist(table)) { BGLTable newTable = tableService.saveTable(table); return new ResponseEntity<>(newTable, HttpStatus.CREATED); }//from w w w. java2s . co m return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:org.exoplatform.acceptance.rest.JsonErrorHandler.java
/** * Catch DuplicateKeyException when an entity creation or update doesn't a constraint of uniqueness in the mongo repository. * * @param ex The exception trapped/*from w w w . j av a2 s. c o m*/ * @return A standardized {@link org.exoplatform.acceptance.rest.JsonErrorResponse} * @throws java.io.IOException if any. */ @ExceptionHandler(DuplicateKeyException.class) @RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public JsonErrorResponse handleDuplicateKeyException(DuplicateKeyException ex) throws IOException { LOGGER.warn("Duplicated Key : {}", ex.getRootCause().getMessage()); return new JsonErrorResponse("Duplicated Key Error", JsonPath.read(ex.getRootCause().getMessage(), "$.err").toString()); }
From source file:org.easyj.rest.controller.AbstractController.java
@ResponseStatus(value = HttpStatus.CONFLICT) @ExceptionHandler(ConflictException.class) public ModelAndView handleConflict(ConflictException ex) { return handleModelAndView(ex); }