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:com.onyxscheduler.web.JobController.java
@RequestMapping(value = "/groups/{group}/jobs/{name}", method = RequestMethod.GET) public ResponseEntity<Job> getJob(@PathVariable String group, @PathVariable String name) { //since ResponseEntity.notFound().build() returns a ResponseEntity<Void> conflicting with ResponseEntity<Job> we have to use this workaround return scheduler.getJob(new JobKey(group, name)).map(ResponseEntity::ok) .orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).body(null)); }
From source file:cn.org.once.cstack.controller.FileController.java
/** * @param containerId/*from ww w . j a va 2s.com*/ * @param path * @return * @throws ServiceException * @throws CheckException */ @RequestMapping(value = "/container/{containerId}", method = RequestMethod.GET) @ResponseBody public ResponseEntity<List<FileUnit>> listByContainerIdAndPath(@PathVariable String containerId, @RequestParam("path") String path) throws ServiceException, CheckException { if (logger.isDebugEnabled()) { logger.debug("containerId:" + containerId); logger.debug("path:" + path); } List<FileUnit> fichiers = fileService.listByContainerIdAndPath(containerId, path); return ResponseEntity.status(HttpStatus.OK).body(fichiers); }
From source file:org.createnet.raptor.auth.service.controller.TokenController.java
@PreAuthorize("isAuthenticated()") @RequestMapping(value = "/token/{tokenId}", method = RequestMethod.PUT) @ApiOperation(value = "Update a token", notes = "", response = Token.class, nickname = "updateToken") public ResponseEntity<?> update(@AuthenticationPrincipal User user, @PathVariable Long tokenId, @RequestBody Token token) {//w w w .j a va 2s . co m // TODO add ACL checks if (user.getId().longValue() != token.getUser().getId().longValue()) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED) .body(new JsonErrorResponse(HttpStatus.UNAUTHORIZED.value(), "Not authorized")); } if (token.getSecret().isEmpty()) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(new JsonErrorResponse(400, "Secret cannot be empty")); } token.setId(tokenId); // Generate the JWT token tokenService.generateToken(token); return ResponseEntity.status(HttpStatus.OK).body(tokenService.update(token)); }
From source file:com.haulmont.restapi.controllers.EntitiesController.java
@GetMapping("/{entityName}/search") public ResponseEntity<String> searchEntitiesListGet(@PathVariable String entityName, @RequestParam String filter, @RequestParam(required = false) String view, @RequestParam(required = false) Integer limit, @RequestParam(required = false) Integer offset, @RequestParam(required = false) String sort, @RequestParam(required = false) Boolean returnNulls, @RequestParam(required = false) Boolean returnCount, @RequestParam(required = false) Boolean dynamicAttributes, @RequestParam(required = false) String modelVersion) { EntitiesSearchResult entitiesSearchResult = entitiesControllerManager.searchEntities(entityName, filter, view, limit, offset, sort, returnNulls, returnCount, dynamicAttributes, modelVersion); ResponseEntity.BodyBuilder responseBuilder = ResponseEntity.status(HttpStatus.OK); if (BooleanUtils.isTrue(returnCount)) { responseBuilder.header("X-Total-Count", entitiesSearchResult.getCount().toString()); }//w w w . j av a2 s . co m return responseBuilder.body(entitiesSearchResult.getJson()); }
From source file:com.yoncabt.ebr.ws.ReportWS.java
@RequestMapping(value = { "/ws/1.0/detail/{requestId}" }, method = RequestMethod.GET, produces = "application/json") public ResponseEntity<ReportTask> detail(@PathVariable("requestId") String requestId) { ReportTask task = reportService.detail(requestId); if (task == null) {//balamam logManager.info("output :YOK !!! " + requestId); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); }//from www .j a v a2 s. co m return ResponseEntity.status(HttpStatus.OK).body(task); }
From source file:cn.org.once.cstack.controller.LogController.java
/** * Return the list of possible list files *///from w ww. jav a 2 s . c o m @RequestMapping(value = "/sources/{applicationName}/container/{containerId}", method = RequestMethod.GET) public @ResponseBody ResponseEntity<List<SourceUnit>> findByApplication(@PathVariable String applicationName, @PathVariable String containerId) throws ServiceException, CheckException { if (logger.isDebugEnabled()) { logger.debug("applicationName:" + applicationName); logger.debug("containerId:" + containerId); } List<SourceUnit> sources = fileService.listLogsFilesByContainer(containerId); if (sources.size() == 0) { String defaultFile = fileService.getLogDirectory(containerId); sources.add(new SourceUnit(defaultFile)); } return ResponseEntity.status(HttpStatus.OK).body(sources); }
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 ww w. ja v a 2s.c o m*/ 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:br.com.s2it.snakes.controllers.CarController.java
@CrossOrigin("*") @RequestMapping(value = "/reservation/cancel", method = RequestMethod.PUT) public ResponseEntity<CarReservation> removePassengerIntoReservation( final @RequestParam(value = "reservation") String reservation, final @RequestParam(value = "passengers") Integer passengers) { if (reservation == null || passengers == null || passengers <= 0 || reservation.isEmpty()) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); try {//from w w w. j a va2 s. co m return ResponseEntity.status(HttpStatus.OK) .body(service.removePassengerIntoReservation(reservation, passengers)); } catch (Exception e) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); } }
From source file:de.unimannheim.spa.process.rest.ProjectRestController.java
@RequestMapping(method = RequestMethod.POST) public ResponseEntity<Map<String, Object>> createProject(@RequestParam String projectLabel) { Project projectCreated = spaService.createProject(projectLabel); spaService.saveProject(projectCreated); spaService.createDataPool(projectCreated, "Default DataPool"); return ResponseEntity.status(HttpStatus.CREATED).contentType(JSON_CONTENT_TYPE) .body(serializeProject(projectCreated)); }
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 av a 2 s . c o m 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"); } }