@ApiOperation("Return nautical warnings of given status.") @RequestMapping( method = RequestMethod.GET, path = "/nautical-warnings/{status}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public ResponseEntity<?> nauticalWarnings( @ApiParam(value = "Status", required = true, allowableValues = "DRAFT,PUBLISHED,ARCHIVED") @PathVariable final String status) { final Status s = Status.valueOf(status.toUpperCase()); final String url = String.format("%s?layer=%s", pookiUrl, s.layer); ResponseEntity<byte[]> response = template.getForEntity(url, byte[].class); if (RestUtil.isError(response.getStatusCode())) { response = template.getForEntity(url, byte[].class); } // Pooki unexpectedly returns body in GZip format, try to unzip it // If that fails, expect body to be "plain" byte[] body; try { body = decompress(response.getBody()); } catch (final IOException e) { body = response.getBody(); } if (RestUtil.isError(response.getStatusCode())) { return ResponseEntity.status(response.getStatusCode()).body(body); } return ResponseEntity.ok().body(body); }
/** When a user log out we regenerate a new token */ @RequestMapping(value = "/connected") @JsonView(FlatView.class) public ResponseEntity<String> connected(HttpServletResponse response) { CurrentUser currentUser = applicationContext.getBean(CurrentUser.class); if (currentUser == null || !currentUser.getCredentials().isPresent()) { return ResponseEntity.ok().body(null); } return ResponseEntity.ok() .body( String.format("{\"emseid\" : \"%s\"}", currentUser.getCredentials().get().getEsmeid())); }
@RequestMapping( value = {"/ws/1.0/reportList"}, method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<ReportDefinition>> reportList() throws IOException, JRException { return ResponseEntity.ok(reportService.reportList()); }
@RequestMapping( value = {"/ws/1.0/reports"}, method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<String>> reports() { return ResponseEntity.ok(reportService.reports()); }
@RequestMapping(value = "/oauth/delApp/{TOKEN}/{APPID}", method = RequestMethod.GET) @Timed public ResponseEntity<Void> delApp( @PathVariable("TOKEN") String ott, @PathVariable("APPID") String appId, HttpServletRequest request) throws IOException, JAXBException, TokenNotFoundException, TokenAlreadyUsedException { log.debug("REST ADD CUSTOM APPS. token [{}]", ott); Token token = tokenRepository.findOneByOtt(ott); if (token == null) { throw new TokenNotFoundException(ott); } Person person = token.getPerson(); Application application = token.getApplication(); Application toDelete = applicationRepository.findOne(new Long(appId)); RelPersonApplication relPersonApplication = relPersonApplicationRepository.findOneByApplicationIsAndTokenIs(toDelete, token); log.debug( "REST ADD CUSTOM APPS. person [{}], localid [{}], relPersonApplication [{}]", person, person.getLocalID(), relPersonApplication.getId()); relPersonApplicationRepository.delete(relPersonApplication); return ResponseEntity.ok().build(); }
@RequestMapping( value = "/message/{projectId:\\d+}/{page:\\d+}/{size:\\d+}", method = GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<Message>> fetch( @PathVariable("projectId") String projectId, @PathVariable("page") int page, @PathVariable("size") int size) { Pageable pageable = new PageRequest(page, size); List<Message> messages = Lists.newArrayList(repository.findAll(pageable).iterator()); messages = Lists.newArrayList( messages .stream() .sorted( new Comparator<Message>() { @Override public int compare(Message m1, Message m2) { // TODO Auto-generated method stub return m1.getDateTime() - m2.getDateTime() > 0 ? -1 : 1; } }) .iterator()); return ResponseEntity.ok(messages); }
/** PUT /users -> Updates an existing User. */ @RequestMapping( value = "/users", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed @Transactional @Secured(AuthoritiesConstants.ADMIN) public ResponseEntity<ManagedUserDTO> updateUser(@RequestBody ManagedUserDTO managedUserDTO) throws URISyntaxException { log.debug("REST request to update User : {}", managedUserDTO); return Optional.of(userRepository.findOne(managedUserDTO.getId())) .map( user -> { user.setLogin(managedUserDTO.getLogin()); user.setFirstName(managedUserDTO.getFirstName()); user.setLastName(managedUserDTO.getLastName()); user.setEmail(managedUserDTO.getEmail()); user.setActivated(managedUserDTO.isActivated()); user.setLangKey(managedUserDTO.getLangKey()); Set<Authority> authorities = user.getAuthorities(); authorities.clear(); managedUserDTO .getAuthorities() .stream() .forEach(authority -> authorities.add(authorityRepository.findOne(authority))); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("user", managedUserDTO.getLogin())) .body(new ManagedUserDTO(userRepository.findOne(managedUserDTO.getId()))); }) .orElseGet(() -> new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); }
@RequestMapping(path = "/auth/{cardId}", method = GET) public ResponseEntity authPersonDiscountCard(@PathVariable long cardId) { return ResponseEntity.ok( JsonNodeFactory.instance .objectNode() .put("authPersonCard", service.authPersonDiscountCard(cardId))); }
/** * PUT /users : Updates an existing User. * * @param managedUserVM the user to update * @return the ResponseEntity with status 200 (OK) and with body the updated user, or with status * 400 (Bad Request) if the login or email is already in use, or with status 500 (Internal * Server Error) if the user couldn't be updated */ @PutMapping("/users") @Timed @Secured(AuthoritiesConstants.ADMIN) public ResponseEntity<ManagedUserVM> updateUser(@RequestBody ManagedUserVM managedUserVM) { log.debug("REST request to update User : {}", managedUserVM); Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail()); if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) { return ResponseEntity.badRequest() .headers( HeaderUtil.createFailureAlert( "userManagement", "emailexists", "E-mail already in use")) .body(null); } existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase()); if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) { return ResponseEntity.badRequest() .headers( HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use")) .body(null); } userService.updateUser( managedUserVM.getId(), managedUserVM.getLogin(), managedUserVM.getFirstName(), managedUserVM.getLastName(), managedUserVM.getEmail(), managedUserVM.isActivated(), managedUserVM.getLangKey(), managedUserVM.getAuthorities()); return ResponseEntity.ok() .headers(HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin())) .body(new ManagedUserVM(userService.getUserWithAuthorities(managedUserVM.getId()))); }
@RequestMapping( value = {"/ws/1.0/dataSourceNames"}, method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<String>> dataSourceNames() { return ResponseEntity.ok(new ArrayList<String>(reportService.dataSourceNames())); }
@RequestMapping(value = "/customers/{id}", method = RequestMethod.GET) ResponseEntity<Resource<Customer>> get(@PathVariable Long id) { return this.customerRepository .findById(id) .map(c -> ResponseEntity.ok(this.customerResourceAssembler.toResource(c))) .orElseThrow(() -> new CustomerNotFoundException(id)); }
@RequestMapping(value = "/", method = RequestMethod.GET) @ApiOperation(value = "find all person", notes = "retrieve all users", httpMethod = "GET") public ResponseEntity<List<Person>> getPersons() { List<Person> result = maps.entrySet().stream().parallel().map(Map.Entry::getValue).collect(Collectors.toList()); log.info("+++ java8 map.value to list {}", result); return ResponseEntity.ok(Lists.newArrayList(maps.values())); }
@RequestMapping(value = "users", method = RequestMethod.POST) public ResponseEntity<?> add(@RequestBody User user) throws SQLException, UnAuthorizedException { if (StringUtils.isEmpty(user.getName()) || StringUtils.isEmpty(user.getSex())) { throw UnAuthorizedException.newInstance(); } userService.add(user); return ResponseEntity.ok().build(); }
@RequestMapping(path = "/get/{cardId}", method = GET, produces = APPLICATION_JSON_VALUE) @ResponseStatus(OK) public ResponseEntity findAvailable(@PathVariable long cardId) { Optional<DiscountCard> dc = service.getCard(cardId); if (!dc.isPresent()) { return ResponseEntity.status(NOT_FOUND).build(); } return ResponseEntity.ok(dc.get()); }
@RequestMapping(path = "/get/by/tags", method = GET, produces = APPLICATION_JSON_VALUE) @JsonView(DiscountCardView.BasicLevel.class) public ResponseEntity getByTags(@RequestParam(required = true) Set<String> tags) { Optional<List<DiscountCard>> discountCards = service.searchByTags(tags); if (discountCards.isPresent()) { return ResponseEntity.ok(discountCards.get()); } return ResponseEntity.status(NOT_FOUND).build(); }
@RequestMapping(path = "/get/by/number", method = GET, produces = APPLICATION_JSON_VALUE) @JsonView(DiscountCardView.BasicLevel.class) public ResponseEntity getByCardNumber(@RequestParam(required = true) long number) { Optional<DiscountCard> discountCards = service.searchByCardNumber(number); if (discountCards.isPresent()) { return ResponseEntity.ok(discountCards.get()); } return ResponseEntity.status(NOT_FOUND).build(); }
@Override @RequestMapping(path = "/{id}", method = RequestMethod.GET) @ResponseBody public ResponseEntity<DataDTO> getData(@PathVariable(value = "id") Long id) { return dataService .getData(id) .map(d -> ResponseEntity.ok(DataDTO.to(d))) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }
/** * DELETE /users/:login : delete the "login" User. * * @param login the login of the user to delete * @return the ResponseEntity with status 200 (OK) */ @DeleteMapping("/users/{login:"******"}") @Timed @Secured(AuthoritiesConstants.ADMIN) public ResponseEntity<Void> deleteUser(@PathVariable String login) { log.debug("REST request to delete User: {}", login); userService.deleteUser(login); return ResponseEntity.ok() .headers(HeaderUtil.createAlert("userManagement.deleted", login)) .build(); }
@RequestMapping( value = "/message/{projectId:\\d+}", method = POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Message> create( @PathVariable("projectId") String projectId, @RequestBody Map<String, Object> params) { Message message = (Message) mesCraTrans.execute(params, projectId); return ResponseEntity.ok(message); }
/** DELETE /purchasedRiskItems/:id -> delete the "id" purchasedRiskItem. */ @RequestMapping( value = "/purchasedRiskItems/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Void> deletePurchasedRiskItem(@PathVariable Long id) { log.debug("REST request to delete PurchasedRiskItem : {}", id); purchasedRiskItemRepository.delete(id); return ResponseEntity.ok() .headers(HeaderUtil.createEntityDeletionAlert("purchasedRiskItem", id.toString())) .build(); }
@RequestMapping( method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Task> updateTask(@RequestBody Task task) { taskService.save(task); LOGGER.info("task id = '" + task.getId() + "' has been "); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("task", task.getTitle())) .body(taskService.findById(task.getId())); }
/** * Löscht eine CompanyBaseInfo. * * @param oid * @return */ @RolesAllowed({"PERM_deleteCompanyBaseInfo"}) @RequestMapping( value = "/{oid}", method = {RequestMethod.DELETE}) public ResponseEntity deleteCompanyBaseInfo(@PathVariable("oid") String oid) { if (LOG.isDebugEnabled()) { LOG.debug("delete companyBaseInfos"); } this.service.delete(oid); return ResponseEntity.ok().build(); }
@RequestMapping(value = "/create", method = RequestMethod.POST) public ResponseEntity<String> createHomework(HttpServletRequest request) { User currentTeacher = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (homeworkService.saveHomework(request, currentTeacher.getId())) { return ResponseEntity.ok("Домашняя работа была добавлена"); } else { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body("Проверьте правильность заполнения полей"); } }
@RequestMapping(path = "/system/monitor") public ResponseEntity<RestResponse> monitor( Authentication authentication, HttpServletRequest request) throws Throwable { Map<String, Object> monitor = new HashMap<>(); monitor.put( "time", DateFormatUtils.ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT.format(new Date())); RestResponse response = new RestResponse(); response.setResultCode(HttpStatus.OK.value()); response.setResultMessage(HttpStatus.OK.getReasonPhrase()); response.setData(monitor); return ResponseEntity.ok(response); }
/** DELETE /customAdmissionDetailss/:id -> delete the "id" customAdmissionDetails. */ @RequestMapping( value = "/customAdmissionDetailss/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Void> deleteCustomAdmissionDetails(@PathVariable Long id) { log.debug("REST request to delete CustomAdmissionDetails : {}", id); customAdmissionDetailsRepository.delete(id); return ResponseEntity.ok() .headers(HeaderUtil.createEntityDeletionAlert("customAdmissionDetails", id.toString())) .build(); }
@RequestMapping( value = "/message/{id:\\d+}", method = PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Message> update( @PathVariable("id") String id, @RequestBody Map<String, Object> params) { Message message = repository.findOne(id); message.update(params); repository.save(message); return ResponseEntity.ok(message); }
/** DELETE /projects/:id -> delete the "id" project. */ @RequestMapping( value = "/projects/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Void> deleteProject(@PathVariable String id) { log.debug("REST request to delete Project : {}", id); projectService.delete(id); return ResponseEntity.ok() .headers(HeaderUtil.createEntityDeletionAlert("project", id.toString())) .build(); }
@RequestMapping(value = "${cerberus.route.authentication.refresh}", method = RequestMethod.GET) public ResponseEntity<?> authenticationRequest(HttpServletRequest request) { String token = request.getHeader(this.tokenHeader); String username = this.tokenUtils.getUsernameFromToken(token); CerberusUser user = (CerberusUser) this.userDetailsService.loadUserByUsername(username); if (this.tokenUtils.canTokenBeRefreshed(token, user.getLastPasswordReset())) { String refreshedToken = this.tokenUtils.refreshToken(token); return ResponseEntity.ok(new AuthenticationResponse(refreshedToken)); } else { return ResponseEntity.badRequest().body(null); } }
// <3> @RequestMapping(method = RequestMethod.GET) ResponseEntity<Resources<Object>> root() { Resources<Object> objects = new Resources<>(Collections.emptyList()); URI uri = MvcUriComponentsBuilder.fromMethodCall( MvcUriComponentsBuilder.on(getClass()).getCollection()) .build() .toUri(); Link link = new Link(uri.toString(), "customers"); objects.add(link); return ResponseEntity.ok(objects); }
@RequestMapping(value = "/customers", method = RequestMethod.OPTIONS) ResponseEntity<?> options() { return ResponseEntity.ok() .allow( HttpMethod.GET, HttpMethod.POST, HttpMethod.HEAD, HttpMethod.OPTIONS, HttpMethod.PUT, HttpMethod.DELETE) .build(); }