List of usage examples for org.springframework.http ResponseEntity ok
public static <T> ResponseEntity<T> ok(T body)
From source file:org.icgc.dcc.metadata.server.resource.EntityResource.java
@RequestMapping public ResponseEntity<List<Entity>> find(@RequestParam("gnosId") String gnosId, @RequestParam("fileName") String fileName) { List<Entity> entities = Lists.newArrayList(); if (isNullOrEmpty(gnosId) && isNullOrEmpty(fileName)) { entities = repository.findAll(); } else if (isNullOrEmpty(gnosId)) { entities = repository.findByFileName(fileName); } else if (isNullOrEmpty(fileName)) { entities = repository.findByGnosId(gnosId); } else {/*from ww w . java 2s.co m*/ entities = repository.findByGnosIdAndFileName(gnosId, fileName); } return ResponseEntity.ok(entities); }
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 v a 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:com.organization.projectname.controller.AuthenticationController.java
@RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST) public ResponseEntity<?> createAuthenticationToken(@RequestBody AuthenticationRequest authenticationRequest, Device device) throws AuthenticationException, Exception { userService.isIPOK();//from www . ja v a 2s . co m // Perform the security final Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(authenticationRequest.getUsername(), authenticationRequest.getPassword())); SecurityContextHolder.getContext().setAuthentication(authentication); // Reload password post-security so we can generate token final UserDetails userDetails = userService.loadUserByUsername(authenticationRequest.getUsername()); final String token = jwtTokenUtil.generateToken(userDetails, device); // Return the token return ResponseEntity.ok(new AuthenticationResponse(token)); }
From source file:org.farrukh.template.rest.inbound.RestInboundGateway.java
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<LibraryResource>> retrieveAllLibraries() { try {// w w w . ja va 2s. co m List<Library> libraries = coreService.getLibraries(); List<LibraryResource> libraryResources = assembler.toResources(libraries); return ResponseEntity.ok(libraryResources); } catch (Exception e) { throw new LibraryRetrievalError(RestFeedbackContext.SOME_FEEDBACK, e); } }
From source file:com.fns.grivet.controller.NamedQueryController.java
@PreAuthorize("hasAuthority('execute:query')") @GetMapping("/api/v1/query/{name}") public ResponseEntity<?> executeNamedQuery(@PathVariable("name") String name, @RequestParam MultiValueMap<String, ?> parameters) { return ResponseEntity.ok(namedQueryService.get(name, parameters)); }
From source file:org.leandreck.endpoints.examples.lombok.LombokTypeScriptEndpoint.java
@RequestMapping(value = "/upload/{id}", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) public ResponseEntity<LombokResponse<List<RootType>, List<Object>, Boolean, SubType, RootType>> fileUpload( @PathVariable("id") long id, @RequestParam("uploadfile") MultipartFile uploadfile, @Context HttpServletRequest request) { // do something return ResponseEntity.ok(new LombokResponse<>()); }
From source file:io.pivotal.strepsirrhini.chaosloris.web.ApplicationController.java
@Transactional(readOnly = true) @RequestMapping(method = GET, value = "/{id}", produces = HAL_JSON_VALUE) public ResponseEntity read(@PathVariable Long id) { Application application = this.applicationRepository.getOne(id); return ResponseEntity.ok(this.applicationResourceAssembler.toResource(application)); }
From source file:org.n52.restfulwpsproxy.webapp.rest.JobController.java
@RequestMapping(value = "/{jobId:.+}/exceptions", method = RequestMethod.GET) public ResponseEntity<ExceptionReportDocument> getExceptions(@PathVariable("processId") String processId, @PathVariable("jobId") String jobId, HttpServletRequest request) { return ResponseEntity.ok(client.getExceptions(processId, jobId)); }
From source file:com.yoncabt.ebr.ws.ReportWS.java
@RequestMapping(value = { "/ws/1.0/reports" }, method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<String>> reports() { return ResponseEntity.ok(reportService.reports()); }
From source file:org.n52.tamis.rest.controller.capabilities.CapabilitiesController.java
/** * //from w ww. ja va 2 s .com * Returns the shortened WPS capabilities document. * * @param serviceID * inside the URL the variable * {@link URL_Constants_TAMIS#SERVICE_ID_VARIABLE_NAME} specifies * the id of the service. * @return shortened capabilities document */ @RequestMapping("") @ResponseBody public ResponseEntity<Capabilities_Tamis> getCapabilities( @PathVariable(URL_Constants_TAMIS.SERVICE_ID_VARIABLE_NAME) String serviceId, HttpServletRequest request) { /* * Delegates the incoming request to the WPS proxy instance, fetches the * extended capabilities document, shortens it and sends it back */ logger.info("Received capabilities request for service id \"{}\"!", serviceId); this.parameterValueStore.addParameterValuePair(URL_Constants_TAMIS.SERVICE_ID_VARIABLE_NAME, serviceId); Capabilities_Tamis capabilitiesDoc = capRequestForwarder.forwardRequestToWpsProxy(request, null, this.parameterValueStore); // return to client; will be converted to JSON implicitly return ResponseEntity.ok(capabilitiesDoc); }