List of usage examples for org.springframework.http ResponseEntity status
Object status
To view the source code for org.springframework.http ResponseEntity status.
Click Source Link
From source file:de.unimannheim.spa.process.rest.ProjectRestController.java
@RequestMapping(value = "/{projectID}/processes", method = RequestMethod.POST) public ResponseEntity<Object> createProcessWithFile(@PathVariable("projectID") String projectID, @RequestParam("processLabel") String processLabel, @RequestParam("format") String format, @RequestPart("processFile") MultipartFile processFile) throws IllegalStateException, IOException { ResponseEntity<Object> resp = null; if (spaService.findProjectById(PROJECT_BASE_URL + projectID).isPresent()) { Project project = spaService.findProjectById(PROJECT_BASE_URL + projectID).get(); final DataPool dataPool = project.getDataPools().get(0); File fileToImport = FileUtils.convertMultipartToFile(processFile); DataBucket process = spaService.importData(fileToImport, format, processLabel, dataPool); fileToImport.delete();//from w w w . j ava2s . c om resp = ResponseEntity.status(HttpStatus.CREATED).contentType(JSON_CONTENT_TYPE).body(process); } else { resp = ResponseEntity.status(HttpStatus.NOT_FOUND).contentType(JSON_CONTENT_TYPE).body(null); } return resp; }
From source file:de.unimannheim.spa.process.rest.ProjectRestController.java
@RequestMapping(value = "/importformats", method = RequestMethod.GET) public ResponseEntity<List<String>> getSupportedImportFormats() { return ResponseEntity.status(HttpStatus.OK).contentType(JSON_CONTENT_TYPE) .body(spaService.getSupportedImportFormats()); }
From source file:br.com.s2it.snakes.controllers.CarController.java
@CrossOrigin("*") @RequestMapping(value = "/reservation", method = RequestMethod.GET) public ResponseEntity<List<CarForReservationVO>> listCarsForReservation( @RequestParam(value = "initialDate") final String initialDate, @RequestParam(value = "finalDate") final String finalDate) { if (finalDate == null || initialDate == null) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); }//from w w w.j a v a2 s . c o m try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); Date initial = sdf.parse(initialDate); Date end = sdf.parse(finalDate); List<CarReservation> reservations = service.listPossibleReservations(initial, end); List<Car> cars = service.listAllCars(); List<CarForReservationVO> possibleCars = new ArrayList<>(); for (Car car : cars) { CarForReservationVO crvo = new CarForReservationVO(); crvo.setPassengers(0); for (CarReservation reservation : reservations) { if (car.getLicensePlate().equals(reservation.getLicensePlate())) { crvo.setPassengers(reservation.getPassengers()); crvo.setReservationId(reservation.getId()); break; } } crvo.setId(car.getId()); crvo.setModel(car.getModel()); crvo.setName(car.getName()); crvo.setPicture(car.getPicture()); crvo.setLicensePlate(car.getLicensePlate()); possibleCars.add(crvo); } return ResponseEntity.ok(possibleCars); } catch (Exception e) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); } }
From source file:de.unimannheim.spa.process.rest.ProjectRestController.java
@RequestMapping(value = "/{projectID}/processes/{processID}", method = RequestMethod.DELETE) public ResponseEntity<Void> deleteProcessFromProject(@PathVariable("projectID") String projectID, @PathVariable("processID") String processID) { BodyBuilder resp = null;/*from w w w . j a va2 s . c o m*/ final Optional<DataPool> dataPool = spaService.findProjectById(PROJECT_BASE_URL + projectID) .map(project -> project.getDataPools().get(0)); final Optional<DataBucket> dataBucketToRemove = (dataPool.isPresent()) ? dataPool.get().findDataBucketById(PROCESS_BASE_URL + processID) : Optional.empty(); if (dataPool.isPresent() && dataBucketToRemove.isPresent()) { spaService.removeDataBucket(dataPool.get(), dataBucketToRemove.get()); resp = ResponseEntity.status(HttpStatus.OK); } else { resp = ResponseEntity.status(HttpStatus.NOT_FOUND); } return resp.build(); }
From source file:br.com.s2it.snakes.controllers.CarController.java
@CrossOrigin("*") @RequestMapping("/{licensePlate}") public ResponseEntity<Car> listByLicensePlate(@PathVariable(value = "licensePlate") final String licensePlate) { if (licensePlate == null) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); }// w ww .j a v a 2 s. co m try { Car car = service.findByLicensePlate(licensePlate); if (car != null && car.getId() != null) return ResponseEntity.ok(car); } catch (Exception e) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); } return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); }
From source file:br.com.s2it.snakes.controllers.CarController.java
@RequestMapping("/testeReservation") public ResponseEntity<CarReservation> testeReservation() { CarReservation r = new CarReservation(); r.setCustomer("usuario"); r.setDestiny("destino"); r.setFinalReservationDate(new Date()); r.setInitialReservationDate(new Date()); r.setLicensePlate("placa"); r.setPassengers(2);/*from w w w .j a v a 2 s. co m*/ return ResponseEntity.status(HttpStatus.OK).body(r); }
From source file:jp.classmethod.aws.brian.web.TriggerController.java
/** * Delete specified trigger.// w w w .j ava 2 s . c om * * @param triggerGroupName trigger group name * @param triggerName trigger name * @return wherther the trigger is removed * @throws SchedulerException */ @ResponseBody @RequestMapping(value = "/triggers/{triggerGroupName}/{triggerName}", method = RequestMethod.DELETE) public ResponseEntity<?> deleteTrigger(@PathVariable("triggerGroupName") String triggerGroupName, @PathVariable("triggerName") String triggerName) throws SchedulerException { logger.info("deleteTrigger {}.{}", triggerGroupName, triggerName); TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName); if (scheduler.checkExists(triggerKey) == false) { return ResponseEntity.notFound().build(); } boolean deleted = scheduler.unscheduleJob(triggerKey); if (deleted) { return ResponseEntity.ok(new BrianResponse<>(true, "ok")); } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BrianResponse<>(false, "unschedule failed")); } }
From source file:com.mocktpo.api.LicenseApiController.java
@RequestMapping(value = "/api/licenses/require", method = RequestMethod.POST) public ResponseEntity<Void> require(@RequestBody RequireActivationVo vo) { logger.debug("{}.{}() accessed.", this.getClass().getSimpleName(), Thread.currentThread().getStackTrace()[1].getMethodName()); String email = vo.getEmail(); String hardware = vo.getHardware(); List<License> lz = service.findByEmail(email); if (null != lz && lz.size() > 0) { // email exists, filled in by agents previously. License lic = lz.get(0);//from w w w . j a v a 2s.co m String licensedHardware = lic.getHardware(); if (StringUtils.isEmpty(licensedHardware)) { // hardware remains blank lic.setHardware(hardware); Date date = new Date(); lic.setDateUpdated(date); service.update(lic); EmailUtils.sendActivationCode(lic); return ResponseEntity.ok().build(); } else { if (licensedHardware.equals(hardware)) { // same hardware registered EmailUtils.sendActivationCode(lic); return ResponseEntity.ok().build(); } else { return ResponseEntity.status(HttpStatus.CONFLICT).build(); // different hardware registered } } } else { return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); // email never exists } }
From source file:com.thinkbiganalytics.metadata.rest.client.MetadataClient.java
private <R> R handle(ResponseEntity<R> resp) { if (resp.getStatusCode().is2xxSuccessful()) { return resp.getBody(); } else {//from w w w . j a va 2 s.c o m throw new WebResponseException( ResponseEntity.status(resp.getStatusCode()).headers(resp.getHeaders()).build()); } }
From source file:com.yunmel.syncretic.core.BaseController.java
/** * /*from w w w .ja v a 2 s.c o m*/ * * @param e * @return */ protected ResponseEntity<Result> error(BaseException e) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(Result.build(e.getCode(), e.getMessage())); }