List of usage examples for org.springframework.http ResponseEntity ok
public static <T> ResponseEntity<T> ok(T body)
From source file:org.n52.restfulwpsproxy.webapp.rest.ProcessController.java
@RequestMapping(value = "/{processId:.+}/jobs", method = RequestMethod.POST) public ResponseEntity<?> execute(@PathVariable("processId") String processId, @RequestParam(value = "sync-execute", required = false, defaultValue = "false") boolean syncExecute, @RequestBody ExecuteDocument executeDocument, HttpServletRequest request) throws URISyntaxException { if (!syncExecute) { executeDocument.getExecute().setMode(ExecuteRequestType.Mode.Enum.forString("async")); StatusInfoDocument asyncExecute = executeClient.asyncExecute(processId, executeDocument); String jobId = asyncExecute.getStatusInfo().getJobID(); URI created = URI.create(request.getRequestURL().append("/").append(jobId).toString()); getJobsClient.addJobId(processId, jobId); return ResponseEntity.created(created).build(); } else {/* w ww .j a va2 s . c om*/ executeDocument.getExecute().setMode(ExecuteRequestType.Mode.Enum.forString("sync")); ResultDocument execute = executeClient.syncExecute(processId, executeDocument); return ResponseEntity.ok(execute); } }
From source file:io.pivotal.strepsirrhini.chaosloris.web.ScheduleController.java
@Transactional(readOnly = true) @RequestMapping(method = GET, value = "", produces = HAL_JSON_VALUE) public ResponseEntity list(Pageable pageable, PagedResourcesAssembler<Schedule> pagedResourcesAssembler) { Page<Schedule> schedules = this.scheduleRepository.findAll(pageable); return ResponseEntity.ok(pagedResourcesAssembler.toResource(schedules, this.scheduleResourceAssembler)); }
From source file:com.orange.clara.tool.controllers.api.WatchedResourcesController.java
@RequestMapping(method = RequestMethod.GET, value = "/{id}") public ResponseEntity<?> getWatchedResource(@PathVariable Integer id) { User user = this.getCurrentUser(); WatchedResource watchedResource = this.watchedResourceRepo.findOne(id); if (!watchedResource.isPublic() && !watchedResource.hasUser(user)) { return ResponseEntity.notFound().build(); }//from w w w . jav a 2s . c o m return ResponseEntity.ok(this.generateResource(watchedResource)); }
From source file:alfio.controller.EventController.java
@RequestMapping(value = "/", method = RequestMethod.HEAD) public ResponseEntity<String> replyToProxy() { return ResponseEntity.ok("Up and running!"); }
From source file:com.github.lynxdb.server.api.http.handlers.EpVhost.java
@RequestMapping(value = "/{vhostUUID}/user", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity listUser(Authentication _authentication, @PathVariable("vhostUUID") UUID vhostId) { Vhost vhost = vhosts.byId(vhostId);/*www . j ava 2 s. com*/ if (vhost == null) { return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, "Vhost does not exist.", null).response(); } List<User> userList = users.byVhost(vhost); return ResponseEntity.ok(userList); }
From source file:io.ignitr.dispatchr.manager.controller.client.ClientsController.java
/** * Finds all clients in the system./*from www . j a v a 2 s .c om*/ * * @param offset starting offset when using pagination * @param limit number of records to return when using pagination * @param sortDir sort direction of records when using pagination * @param httpRequest http request * @return an HTTP 200 response containing a list of all clients defined in the system */ @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public DeferredResult<ResponseEntity<?>> findAll( @RequestParam(value = "offset", defaultValue = "0") Long offset, @RequestParam(value = "limit", defaultValue = "25") Long limit, @RequestParam(value = "sort_dir", defaultValue = "asc") String sortDir, @RequestParam(value = "active", defaultValue = "true") Boolean active, HttpServletRequest httpRequest) { final DeferredResult<ResponseEntity<?>> deferredResult = new DeferredResult<>(); Observable.fromCallable(() -> SortDirectionValidator.validate(sortDir)) .lift(new RequestContextStashOperator<>()) .flatMap(valid -> Observable.create(new Observable.OnSubscribe<List<Client>>() { List<Client> clients = new ArrayList<>(); @Override public void call(Subscriber<? super List<Client>> subscriber) { service.findAll(offset, limit, sortDir, active).collect(() -> clients, List::add) .subscribe(clients -> { subscriber.onNext(clients); subscriber.onCompleted(); }); } })).map(FindClientsResponse::from).subscribeOn(Schedulers.io()).subscribe(body -> { deferredResult.setResult(ResponseEntity.ok(body)); }, error -> { deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error)); }); return deferredResult; }
From source file:org.n52.tamis.rest.controller.processes.SingleProcessDescriptionController.java
/** * Returns the shortened single process description. * //w w w . ja v a 2 s .c o m * @param serviceID * inside the URL the variable * {@link URL_Constants_TAMIS#SERVICE_ID_VARIABLE_NAME} specifies * the id of the service. * @param request * @param processId * inside the URL the variable * {@link URL_Constants_TAMIS#PROCESS_ID_VARIABLE_NAME} specifies * the id of the process. * @param request * @return the shortened single process description */ @RequestMapping("") @ResponseBody public ResponseEntity<ProcessDescription_singleProcess> getSingleProcessDescription( @PathVariable(URL_Constants_TAMIS.SERVICE_ID_VARIABLE_NAME) String serviceId, @PathVariable(URL_Constants_TAMIS.PROCESS_ID_VARIABLE_NAME) String processId, HttpServletRequest request) { logger.info("Received single process description request for service id \"{}\" and process id \"{}\"!", serviceId, processId); parameterValueStore.addParameterValuePair(URL_Constants_TAMIS.SERVICE_ID_VARIABLE_NAME, serviceId); parameterValueStore.addParameterValuePair(URL_Constants_TAMIS.PROCESS_ID_VARIABLE_NAME, processId); ProcessDescription_singleProcess singleProcessDescription = sProcessDescrRequestForwarder .forwardRequestToWpsProxy(request, null, parameterValueStore); return ResponseEntity.ok(singleProcessDescription); }
From source file:org.createnet.raptor.auth.service.controller.AuthenticationController.java
@RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST) @ApiOperation(value = "Login an user with provided credentials", notes = "", response = JwtResponse.class, nickname = "login") public ResponseEntity<?> login(@RequestBody JwtRequest authenticationRequest) throws AuthenticationException { try {//from w w w .j a va 2s.com final Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(authenticationRequest.username, authenticationRequest.password)); SecurityContextHolder.getContext().setAuthentication(authentication); // Reload password post-security so we can generate token final UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationRequest.username); final Token token = tokenService.createLoginToken((User) userDetails); // Return the token return ResponseEntity.ok(new JwtResponse((User) userDetails, token.getToken())); } catch (AuthenticationException ex) { logger.error("Authentication exception: {}", ex.getMessage()); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Authentication failed"); } }
From source file:com.coinblesk.server.controller.UserController.java
@RequestMapping(value = "/login", method = POST, consumes = APPLICATION_JSON_UTF8_VALUE, produces = APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<?> login(@Valid @RequestBody LoginDTO loginDTO, HttpServletResponse response) { UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken( loginDTO.getUsername().toLowerCase(Locale.ENGLISH), loginDTO.getPassword()); try {/*from w ww.j ava 2s.c om*/ Authentication authentication = this.authenticationManager.authenticate(authenticationToken); SecurityContextHolder.getContext().setAuthentication(authentication); String jwt = tokenProvider.createToken(authentication); response.addHeader(JWTConfigurer.AUTHORIZATION_HEADER, "Bearer " + jwt); return ResponseEntity.ok(Collections.singletonMap("token", jwt)); } catch (AuthenticationException exception) { return new ResponseEntity<>( Collections.singletonMap("AuthenticationException", exception.getLocalizedMessage()), HttpStatus.UNAUTHORIZED); } }
From source file:alfio.controller.EventController.java
@RequestMapping(value = "/healthz", method = RequestMethod.GET) public ResponseEntity<String> replyToK8s() { return ResponseEntity.ok("Up and running!"); }