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:com.agroservices.restcontrollers.ProductosEnVentaRest.java
/** * Mtodo encargado de recibir la petici de POST para el producto en venta a modificar y manejar de forma adecuada dicha peticin * @param elemento// w w w. j a v a2 s.c o m * @return */ @RequestMapping(value = "/modificarProductoEnVenta", method = RequestMethod.POST) public ResponseEntity<?> modificarProductoVenta(@RequestBody ProductoEnVenta elemento) { if (pef.modificarProductoEnVenta(elemento)) { return new ResponseEntity<>(HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.CONFLICT); } }
From source file:org.trustedanalytics.user.invite.RestErrorHandler.java
@ResponseBody @ResponseStatus(HttpStatus.CONFLICT) @ExceptionHandler(TooShortPasswordException.class) public String tooShortPassword(Exception e) throws IOException { return e.getMessage(); }
From source file:org.createnet.raptor.auth.service.controller.RoleController.java
@PreAuthorize("hasAuthority('admin') or hasAuthority('super_admin')") @RequestMapping(value = { "/role" }, method = RequestMethod.POST) @ApiOperation(value = "Create a new role", notes = "", response = Role.class, nickname = "createRole") @ApiResponses(value = { @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 409, message = "Conflict") }) public ResponseEntity<?> create(@AuthenticationPrincipal RaptorUserDetailsService.RaptorUserDetails currentUser, @RequestBody Role rawRole) { if ((rawRole.getName().isEmpty() || rawRole.getName() == null)) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Name property is missing"); }/*from w ww . j a v a2s. c om*/ Role role2 = roleService.getByName(rawRole.getName()); if (role2 != null) { return ResponseEntity.status(HttpStatus.CONFLICT).body(null); } Role role = roleService.create(rawRole); if (role == null) { return ResponseEntity.status(HttpStatus.CONFLICT).body(null); } logger.debug("Created role {}", role.getName()); return ResponseEntity.ok(role); }
From source file:nc.noumea.mairie.organigramme.core.ws.BaseWsConsumer.java
public <T> T readResponse(Class<T> targetClass, ClientResponse response, String url) { T result = null;//from w w w . j av a 2 s . co m try { result = targetClass.newInstance(); } catch (Exception ex) { throw new WSConsumerException( "An error occured when instantiating return type when deserializing JSON from WS request.", ex); } if (response.getStatus() == HttpStatus.NO_CONTENT.value()) { return null; } if (response.getStatus() != HttpStatus.OK.value() && response.getStatus() != HttpStatus.CONFLICT.value()) { throw new WSConsumerException( String.format("An error occured when querying '%s'. Return code is : %s, content is %s", url, response.getStatus(), response.getEntity(String.class))); } String output = response.getEntity(String.class); result = new JSONDeserializer<T>().use(Date.class, new MSDateTransformer()).deserializeInto(output, result); return result; }
From source file:gt.dakaik.rest.impl.UserImpl.java
@Override public ResponseEntity<User> doCreate(UserProfile pro, int idUsuario, String token) throws EntidadDuplicadaException, EntidadNoEncontradaException { User user = pro.getUser();/*from w ww .jav a 2 s. co m*/ User u = repoU.findByTxtUser(user.getTxtUser()); Boolean isUser = true; String pwd = ""; Map<String, String> mpResp = new HashMap<>(); if (u == null) { u = new User(); if (user.getPerson() == null) { return new ResponseEntity("msj_person_required", HttpStatus.CONFLICT); } if (user.getPerson().getDocuments().isEmpty()) { throw new EntidadDuplicadaException("msj_document_required"); } List<Document> doctos = new ArrayList<>(); for (Document d : user.getPerson().getDocuments()) { // for (Document d : doctos) { if (d == null || d.getTxtDocument().equals("")) { throw new EntidadDuplicadaException("msj_document_required"); } Document doc = repoDocument.findByTxtDocument(d.getTxtDocument()); if (doc != null) { throw new EntidadDuplicadaException("msj_document"); } DocumentType dt = repoDocumentType.findOne(d.getDocumentType().getIdDocumentType()); if (dt == null) { return new ResponseEntity("msj_document_type_required", HttpStatus.CONFLICT); } doc = new Document(); doc.setDocumentType(dt); doc.setTxtDocument(d.getTxtDocument()); doc.setSnActive(true); doctos.add(doc); } Person p = new Person(); p.setTxtFullName(user.getPerson().getTxtFullName()); p.setTxtFirstNameF(user.getPerson().getTxtFirstNameF()); p.setTxtFirstNameS(user.getPerson().getTxtFirstNameS()); p.setTxtFirstNameT(user.getPerson().getTxtFirstNameT()); p.setTxtLastNameF(user.getPerson().getTxtLastNameF()); p.setTxtLastNameS(user.getPerson().getTxtLastNameS()); p.setTxtLastNameT(user.getPerson().getTxtLastNameT()); p.setSnActive(true); Address ad = new Address(); ad.setIntZone(user.getPerson().getAddress().getIntZone()); ad.setTxtColony(user.getPerson().getAddress().getTxtColony()); ad.setTxtIndications(user.getPerson().getAddress().getTxtIndications()); ad.setTxtNumberHouse(user.getPerson().getAddress().getTxtNumberHouse()); City ct = repoCity.findOne(user.getPerson().getAddress().getCity().getIdCity()); if (ct == null) { throw new EntidadNoEncontradaException("Entity City"); } ad.setCity(ct); p.setAddress(ad); Person person = repoPerson.save(p); doctos.stream().forEach((d) -> { d.setPerson(person); }); repoDocument.save(doctos); pwd = user.getTxtPwd() != null ? user.getTxtPwd() : "UsCollage" + person.getIdPerson(); u.setLastDatePwd(new Date()); u.setIntDaysChangePwd(user.getIntDaysChangePwd() == 0 ? 30 : user.getIntDaysChangePwd()); u.setSnChangePwd(false); u.setIdUser(user.getIdUser()); u.setTxtPwd(CommonEncripta.get_md5(pwd)); u.setTxtUser(user.getTxtUser()); u.setSnActive(true); u.setPerson(person); repoU.save(u); isUser = false; } UserProfile up = new UserProfile(); Profile profile = repoProfile.findOne(pro.getProfile().getIdProfile()); if (profile == null) { mpResp.put("message", "msj_no_existe"); mpResp.put("valor", "profile"); return new ResponseEntity(mpResp, HttpStatus.NOT_FOUND); } up.setProfile(profile); School school = repoSchool.findOne(pro.getLicence().getSchool().getIdSchool()); if (school == null) { mpResp.put("message", "msj_no_existe"); mpResp.put("valor", "school"); return new ResponseEntity(mpResp, HttpStatus.NOT_FOUND); } Licences licence = repoLic.findTopBySchoolAndProfileAndStatusOrderByDatesAsc(school, profile, Status.A); if (licence == null) { mpResp.put("message", "msj_no_hay_licencias"); mpResp.put("valor", "Licence"); return new ResponseEntity(mpResp, HttpStatus.NOT_FOUND); } up.setLicence(licence); up.setIdUserProfile(school.getIdSchool()); if (isUser) { UserProfile upro = repoUProfile.findByLicenceYUserYProfile(school, u, profile); if (upro != null) { throw new EntidadDuplicadaException("User"); } } up.setUser(u); up.setSnActive(true); repoUProfile.save(up); licence.setStatus(Status.U); repoLic.save(licence); String contentEmail = Common.getTemplateSendEmailRegister(u.getTxtUser(), profile.getTxtDescription(), school.getTxtName(), licence.getTxtLicence(), pwd); /*try { MimeMessage mail = Common.createEmail(u.getTxtUser(), "NO-RESPONDER Bienvenido a Colegios GT", contentEmail); Common.sen Common.sendEmail("NO-RESPONDER Bienvenido a Colegios GT", contentEmail, u.getTxtUser()); } catch (Exception e) { }*/ return new ResponseEntity(repoU.findOne(u.getIdUser()), HttpStatus.OK); }
From source file:edu.pitt.dbmi.ccd.anno.error.ErrorHandler.java
@ExceptionHandler(DuplicateKeyException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody/* w ww.java 2 s . c o m*/ public ErrorMessage handleDuplicateKeyException(DuplicateKeyException ex, HttpServletRequest req) { LOGGER.info(ex.getMessage()); return new ErrorMessage(HttpStatus.CONFLICT, ex.getMessage(), req); }
From source file:com.aquest.emailmarketing.web.controllers.RestfulController.java
@RequestMapping(value = "/api/broadcast", method = RequestMethod.POST) public ResponseEntity<Void> createBroadcastFromRest(@RequestBody Broadcast broadcast, UriComponentsBuilder ucBuilder) { System.out.println("Creating Broadcast " + broadcast.getBroadcast_id()); if (broadcastService.isBroadcastExist(broadcast.getBroadcast_id())) { System.out.println("A Broadcast with id " + broadcast.getBroadcast_id() + " already exist"); return new ResponseEntity<Void>(HttpStatus.CONFLICT); }//w ww .jav a 2 s.com Timestamp curTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()); broadcast.setCreation_dttm(curTimestamp); broadcast.setStatus("In definition process"); BroadcastTemplate bcastTemplate = broadcastTemplateService .getBroadcastTemplateById(broadcast.getBcast_template_id()); broadcast.setBroadcast_name(bcastTemplate.getB_template_name()); broadcast.setSubject(bcastTemplate.getB_template_subject()); broadcast.setEmailConfig(bcastTemplate.getEmailConfig()); broadcast.setHtmlbody(bcastTemplate.getHtmlbody()); broadcast.setHtmlbody_embed(bcastTemplate.getHtmlbody_embed()); broadcast.setHtmlbody_tracking(bcastTemplate.getHtmlbody_tracking()); broadcast.setPlaintext(bcastTemplate.getPlaintext()); broadcastService.SaveOrUpdate(broadcast); //dodaje se red u embedded_image sa broadcast_id EmbeddedImage embeddedImage = embeddedImageService .getEmbeddedImagesFromTemplateId(broadcast.getBcast_template_id()); EmbeddedImage embeddedImage1 = new EmbeddedImage(); embeddedImage1.setBroadcast_id(broadcast.getBroadcast_id()); embeddedImage1.setUrl(embeddedImage.getUrl()); embeddedImageService.SaveOrUpdate(embeddedImage1); broadcastService.SaveOrUpdate(broadcast); return new ResponseEntity<Void>(HttpStatus.CREATED); }
From source file:org.osiam.resources.exception.OsiamExceptionHandler.java
@ExceptionHandler(JsonMappingException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody//ww w. j a va2s . co m public ErrorResponse handleJsonMapping(JsonMappingException e) { LOGGER.error("Unable to deserialize", e); return produceErrorResponse(e.getMessage(), HttpStatus.CONFLICT, new JsonMappingMessageTransformer()); }
From source file:net.jkratz.igdb.controller.advice.ErrorController.java
@RequestMapping(produces = "application/json") @ExceptionHandler(DataIntegrityViolationException.class) @ResponseStatus(value = HttpStatus.CONFLICT) public @ResponseBody Map<String, Object> handleDataIntegrityViolationException( DataIntegrityViolationException ex) throws IOException { logger.error("Data Integrity Error", ex); Map<String, Object> map = Maps.newHashMap(); map.put("error", "Data Integrity Error"); map.put("message", ex.getMessage()); if (ex.getRootCause() != null) { map.put("cause", ex.getRootCause().getMessage()); }/* w w w . ja v a 2s . c o m*/ return map; }
From source file:ch.wisv.areafiftylan.seats.controller.SeatRestController.java
/** * Reserve a Seat at a given location. This can be done for yourself, an Admin or a member of a Team you're the * captain of.// w w w . j a va 2 s. c o m * * @param group Group of the Seat * @param number Number in the group of a Seat * @param username Username of the User you want to reserve the Seat for. * * @return Status message indicating the result. */ @PreAuthorize("@currentUserServiceImpl.canReserveSeat(principal, #ticketId)") @RequestMapping(value = "seats/{group}/{number}", method = RequestMethod.POST) ResponseEntity<?> reserveSingleSeat(@PathVariable String group, @PathVariable int number, @RequestParam Long ticketId) { if (seatService.reserveSeatForTicket(group, number, ticketId)) { return createResponseEntity(HttpStatus.OK, "Seat successfully reserved"); } else { return createResponseEntity(HttpStatus.CONFLICT, "Seat is already taken"); } }