Java Code Examples for org.springframework.http.HttpStatus#OK
The following examples show how to use
org.springframework.http.HttpStatus#OK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountResource.java From flair-registry with Apache License 2.0 | 6 votes |
/** * GET /account : get the current user. * * @return the ResponseEntity with status 200 (OK) and the current user in body, or status 500 (Internal Server * Error) if the user couldn't be returned */ @GetMapping("/account") @Timed public ResponseEntity<UserVM> getAccount() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); try { String login; if (authentication.getPrincipal() instanceof User) { User user = (User) authentication.getPrincipal(); login = user.getUsername(); log.debug("The username `{}` has been found using JWT", login); } else if (authentication.getPrincipal() instanceof String) { login = (String) authentication.getPrincipal(); log.debug("The username `{}` has been found using OpenID Connect", login); } else { log.debug("The username could not be found"); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } UserVM userVM = new UserVM(login, authentication.getAuthorities().stream() .map(GrantedAuthority::getAuthority).collect(Collectors.toSet())); return new ResponseEntity<>(userVM, HttpStatus.OK); } catch (NullPointerException | ClassCastException e) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } }
Example 2
Source File: WebExceptionHandler.java From roncoo-pay with Apache License 2.0 | 5 votes |
/** * 总异常 */ @ExceptionHandler({ Exception.class }) @ResponseStatus(HttpStatus.OK) public String processException(Exception e, HttpServletRequest request) { LOG.error("Exception", e); request.setAttribute("msg", "系统异常"); return "common/error"; }
Example 3
Source File: AccoutResource.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
@Log("修改邮箱") @ApiOperation("修改邮箱") @PostMapping(value = "/account/change-email/{code}") public ResponseEntity<Object> updateEmail(@PathVariable String code, @RequestBody UserEmailDto userEmailDto) { // 密码解密 RSA rsa = new RSA(applicationProperties.getRsa().getPrivateKey(), applicationProperties.getRsa().getPublicKey()); String password = new String(rsa.decrypt(userEmailDto.getPassword(), KeyType.PrivateKey)); userEmailDto.setPassword(password); emailService.validated(CommonConstants.EMAIL_RESET_EMAIL_CODE + userEmailDto.getEmail(), code); userService.updateEmail(SecurityUtil.getUser().getUsername(), userEmailDto); return new ResponseEntity<>(HttpStatus.OK); }
Example 4
Source File: UserResource.java From swagger-maven-plugin with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/createWithList", method = RequestMethod.POST) @ApiOperation(value = "Creates list of users with given input array", position = 3) public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object", required = true) @RequestBody java.util.List<User> users) { for (User user : users) { userData.addUser(user); } return new ResponseEntity(HttpStatus.OK); }
Example 5
Source File: CmController.java From SDA with BSD 2-Clause "Simplified" License | 5 votes |
/** * 단건조회 * @param cmid * @return ResponseEntity<ResponseMessage> */ @RequestMapping(value = "/cmcmici/{cmid}", method = RequestMethod.GET) public @ResponseBody ResponseEntity<ResponseMessage> selectCmCmiCiOne(@PathVariable String cmid) { Map<String, Object> commandMap = new HashMap<String, Object>(); ResponseMessage resultMsg = new ResponseMessage(); ResponseEntity<ResponseMessage> entity = null; HttpHeaders responseHeaders = new HttpHeaders(); Gson gson = new Gson(); String contents; log.info("/cmcmici/{cmid} GET start================>"); try { CmCiDTO cmCiDTO = new CmCiDTO(); commandMap.put("cmid", cmid); cmCiDTO = cmService.selectCmCmiCiOne(commandMap); contents = gson.toJson(cmCiDTO); resultMsg.setCode(Utils.OK_CODE); resultMsg.setMessage(Utils.OK_MSG); resultMsg.setContents(contents); entity = new ResponseEntity<ResponseMessage>(resultMsg, responseHeaders, HttpStatus.OK); } catch (Exception e) { e.printStackTrace(); resultMsg = Utils.makeResponseBody(e); responseHeaders.add("ExceptionCause", e.getMessage()); responseHeaders.add("ExceptionClass", e.getClass().getName()); entity = new ResponseEntity<ResponseMessage>(resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode())); } log.info("/cmcmici/{cmid} GET end================>"); return entity; }
Example 6
Source File: UserRESTController.java From Spring-5.0-Projects with MIT License | 5 votes |
@PostMapping(value="/register",consumes= MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<String>> registerNewUser(@Valid @RequestBody UserDTO userDto,Errors errors) { if(userDto.getUsername() != null) { User existingUser = userRepository.findByUsername(userDto.getUsername()); if(existingUser !=null) { errors.reject("Existing username", "User is already exist with usernae '"+userDto.getUsername()+"'. "); } existingUser = userRepository.findByEmail(userDto.getEmail()); if(existingUser !=null) { errors.reject("Existing username", "User is already exist with email '"+userDto.getEmail()+"'. "); } if(!userDto.getPassword().equalsIgnoreCase(userDto.getConfirmPassword())) { errors.reject("password not match", "password and confirm password are not same"); } } if(errors.hasErrors()) { List<String> errorMsg = new ArrayList<String>(); errors.getAllErrors().forEach(a -> errorMsg.add(a.getDefaultMessage())); return new ResponseEntity<List<String>>(errorMsg, HttpStatus.BAD_REQUEST); }else { User userEntity = new User(); userEntity.setUsername(userDto.getUsername()); userEntity.setPassword(passwordEncoder.encode(userDto.getPassword())); userEntity.setEmail(userDto.getEmail()); userEntity.setMobile(userDto.getMobile()); userRepository.save(userEntity); List<String> msgLst = Arrays.asList("User registered successfully"); return new ResponseEntity<List<String>>(msgLst, HttpStatus.OK); } }
Example 7
Source File: EvidenceController.java From oncokb with GNU Affero General Public License v3.0 | 5 votes |
@RequestMapping(value = "/legacy-api/evidences/lastReview/update", method = RequestMethod.POST) public @ResponseBody synchronized ResponseEntity updateEvidenceLastReview(@RequestBody Map<String, Date> lastReviews ) throws ParserConfigurationException { Set<Evidence> updatedEvidences = updateEvidenceLastReviewBasedOnUuids(lastReviews); if (updatedEvidences != null) { updateCacheBasedOnEvidences(updatedEvidences); } return new ResponseEntity(HttpStatus.OK); }
Example 8
Source File: UserController.java From TASK-Management-System with MIT License | 5 votes |
@GetMapping("/getUser/{uid}") @CrossOrigin(origins = clientUrl) @PreAuthorize("hasRole('USER') or hasRole('ADMIN')") public ResponseEntity<UserResource> getUserById(@PathVariable("uid") Long uid) { UserResource ur = new UserResource(); BeanUtils.copyProperties(service.getUser(uid), ur); return new ResponseEntity<UserResource>(ur, HttpStatus.OK); }
Example 9
Source File: TodoListController.java From azure-gradle-plugins with MIT License | 5 votes |
/** * HTTP GET ALL */ @RequestMapping(value = "/api/todolist", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) public ResponseEntity<?> getAllTodoItems() { try { return new ResponseEntity<List<TodoItem>>((List<TodoItem>) todoItemRepository.findAll(), HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<String>("Nothing found", HttpStatus.NOT_FOUND); } }
Example 10
Source File: TaskDefinitionController.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Return a page-able list of {@link TaskDefinitionResource} defined tasks. * * @param pageable page-able collection of {@code TaskDefinitionResource} * @param search optional findByTaskNameContains parameter * @param manifest optional manifest flag to indicate whether the latest task execution requires task manifest update * @param assembler assembler for the {@link TaskDefinition} * @return a list of task definitions */ @RequestMapping(value = "", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public PagedModel<TaskDefinitionResource> list(Pageable pageable, @RequestParam(required = false) String search, @RequestParam(required = false) boolean manifest, PagedResourcesAssembler<TaskExecutionAwareTaskDefinition> assembler) { final Page<TaskDefinition> taskDefinitions; if (search != null) { taskDefinitions = repository.findByTaskNameContains(search, pageable); } else { taskDefinitions = repository.findAll(pageable); } final java.util.HashMap<String, TaskDefinition> taskDefinitionMap = new java.util.HashMap<>(); for (TaskDefinition taskDefinition : taskDefinitions) { taskDefinitionMap.put(taskDefinition.getName(), taskDefinition); } final List<TaskExecution> taskExecutions; if (!taskDefinitionMap.isEmpty()) { taskExecutions = this.explorer.getLatestTaskExecutionsByTaskNames( taskDefinitionMap.keySet().toArray(new String[taskDefinitionMap.size()])); } else { taskExecutions = null; } final Page<TaskExecutionAwareTaskDefinition> taskExecutionAwareTaskDefinitions = taskDefinitions .map(new TaskDefinitionConverter(taskExecutions)); PagedModel<TaskDefinitionResource> taskDefinitionResources = assembler.toModel(taskExecutionAwareTaskDefinitions, new Assembler(manifest)); // Classify the composed task elements by iterating through the task definitions that are part of this page. updateComposedTaskElement(taskDefinitionResources.getContent()); return taskDefinitionResources; }
Example 11
Source File: AdminController.java From Spring-Shiro-Spark with Apache License 2.0 | 5 votes |
@PostMapping(value = SUBPATH_USER) public ResponseEntity<UserDto> addUser(@RequestBody UserDto userDto, UriComponentsBuilder uriComponentsBuilder){ HttpHeaders headers = ApplicationUtil.getHttpHeaders(uriComponentsBuilder,PATH + SUBPATH_USER); User user = convertToEntity(userDto); userService.addUser(user); return new ResponseEntity<UserDto>(headers,HttpStatus.OK); }
Example 12
Source File: AssetGroupController.java From pacbot with Apache License 2.0 | 5 votes |
/** * Gets the all asset group apis. * * @return the all asset group apis */ @RequestMapping(path = "/v1/get-all-asset-group-apis", method = RequestMethod.GET) public ResponseEntity<List<Map<String, Object>>> getAllAssetGroupApis() { try { List<Map<String, Object>> assetGroupDetails = assetGroupService .getAllAssetGroupApis(); return new ResponseEntity<>( assetGroupDetails, HttpStatus.OK); } catch (Exception exception) { LOGGER.error("Exception in sendTextMail:", exception); return new ResponseEntity<>(HttpStatus.FORBIDDEN); } }
Example 13
Source File: ProjectPageController.java From agile-service-old with Apache License 2.0 | 5 votes |
@Permission(type = ResourceType.PROJECT, roles = {InitRoleCode.PROJECT_OWNER}) @ApiOperation(value = "分页查询页面列表") @CustomPageRequest @PostMapping public ResponseEntity<PageInfo<PageVO>> pageQuery(@ApiIgnore @SortDefault(value = "id", direction = Sort.Direction.DESC) PageRequest pageRequest, @ApiParam(value = "项目id", required = true) @PathVariable("project_id") Long projectId, @ApiParam(value = "组织id", required = true) @RequestParam Long organizationId, @ApiParam(value = "search dto", required = true) @RequestBody(required = false) PageSearchVO searchDTO) { return new ResponseEntity<>(pageService.pageQuery(organizationId, pageRequest, searchDTO), HttpStatus.OK); }
Example 14
Source File: ComplianceController.java From pacbot with Apache License 2.0 | 5 votes |
/** * Close issues.ruleDetails expects ruleId,reason and userId, Api returns * true if its successfully closes all issues in ES for that ruleId else * false * * @param ruleDetails the rule details * @return ResponseEntity */ @ApiOperation(httpMethod = "PUT", value = "Close Issues by Rule Details") @RequestMapping(path = "/v1/issues/close-by-rule-id", method = RequestMethod.PUT) @ResponseBody public ResponseEntity<Object> closeIssues( @ApiParam(value = "Provide valid Rule Details ", required = true) @RequestBody(required = true) RuleDetails ruleDetails) { Map<String, Object> response = complianceService.closeIssuesByRule(ruleDetails); if (Integer.parseInt(response.get("status").toString()) == TWO_HUNDRED) { return new ResponseEntity<>(response, HttpStatus.OK); } else { return new ResponseEntity<>(response, HttpStatus.FORBIDDEN); } }
Example 15
Source File: SlingApiController.java From swagger-aem with Apache License 2.0 | 4 votes |
public ResponseEntity<Void> postConfigAdobeGraniteSamlAuthenticationHandler(@ApiParam(value = "") @RequestParam(value = "keyStorePassword", required = false) String keyStorePassword, @ApiParam(value = "") @RequestParam(value = "keyStorePassword@TypeHint", required = false) String keyStorePasswordAtTypeHint, @ApiParam(value = "") @RequestParam(value = "service.ranking", required = false) Integer serviceRanking, @ApiParam(value = "") @RequestParam(value = "service.ranking@TypeHint", required = false) String serviceRankingAtTypeHint, @ApiParam(value = "") @RequestParam(value = "idpHttpRedirect", required = false) Boolean idpHttpRedirect, @ApiParam(value = "") @RequestParam(value = "idpHttpRedirect@TypeHint", required = false) String idpHttpRedirectAtTypeHint, @ApiParam(value = "") @RequestParam(value = "createUser", required = false) Boolean createUser, @ApiParam(value = "") @RequestParam(value = "createUser@TypeHint", required = false) String createUserAtTypeHint, @ApiParam(value = "") @RequestParam(value = "defaultRedirectUrl", required = false) String defaultRedirectUrl, @ApiParam(value = "") @RequestParam(value = "defaultRedirectUrl@TypeHint", required = false) String defaultRedirectUrlAtTypeHint, @ApiParam(value = "") @RequestParam(value = "userIDAttribute", required = false) String userIDAttribute, @ApiParam(value = "") @RequestParam(value = "userIDAttribute@TypeHint", required = false) String userIDAttributeAtTypeHint, @ApiParam(value = "") @RequestParam(value = "defaultGroups", required = false) List<String> defaultGroups, @ApiParam(value = "") @RequestParam(value = "defaultGroups@TypeHint", required = false) String defaultGroupsAtTypeHint, @ApiParam(value = "") @RequestParam(value = "idpCertAlias", required = false) String idpCertAlias, @ApiParam(value = "") @RequestParam(value = "idpCertAlias@TypeHint", required = false) String idpCertAliasAtTypeHint, @ApiParam(value = "") @RequestParam(value = "addGroupMemberships", required = false) Boolean addGroupMemberships, @ApiParam(value = "") @RequestParam(value = "addGroupMemberships@TypeHint", required = false) String addGroupMembershipsAtTypeHint, @ApiParam(value = "") @RequestParam(value = "path", required = false) List<String> path, @ApiParam(value = "") @RequestParam(value = "path@TypeHint", required = false) String pathAtTypeHint, @ApiParam(value = "") @RequestParam(value = "synchronizeAttributes", required = false) List<String> synchronizeAttributes, @ApiParam(value = "") @RequestParam(value = "synchronizeAttributes@TypeHint", required = false) String synchronizeAttributesAtTypeHint, @ApiParam(value = "") @RequestParam(value = "clockTolerance", required = false) Integer clockTolerance, @ApiParam(value = "") @RequestParam(value = "clockTolerance@TypeHint", required = false) String clockToleranceAtTypeHint, @ApiParam(value = "") @RequestParam(value = "groupMembershipAttribute", required = false) String groupMembershipAttribute, @ApiParam(value = "") @RequestParam(value = "groupMembershipAttribute@TypeHint", required = false) String groupMembershipAttributeAtTypeHint, @ApiParam(value = "") @RequestParam(value = "idpUrl", required = false) String idpUrl, @ApiParam(value = "") @RequestParam(value = "idpUrl@TypeHint", required = false) String idpUrlAtTypeHint, @ApiParam(value = "") @RequestParam(value = "logoutUrl", required = false) String logoutUrl, @ApiParam(value = "") @RequestParam(value = "logoutUrl@TypeHint", required = false) String logoutUrlAtTypeHint, @ApiParam(value = "") @RequestParam(value = "serviceProviderEntityId", required = false) String serviceProviderEntityId, @ApiParam(value = "") @RequestParam(value = "serviceProviderEntityId@TypeHint", required = false) String serviceProviderEntityIdAtTypeHint, @ApiParam(value = "") @RequestParam(value = "assertionConsumerServiceURL", required = false) String assertionConsumerServiceURL, @ApiParam(value = "") @RequestParam(value = "assertionConsumerServiceURL@TypeHint", required = false) String assertionConsumerServiceURLAtTypeHint, @ApiParam(value = "") @RequestParam(value = "handleLogout", required = false) Boolean handleLogout, @ApiParam(value = "") @RequestParam(value = "handleLogout@TypeHint", required = false) String handleLogoutAtTypeHint, @ApiParam(value = "") @RequestParam(value = "spPrivateKeyAlias", required = false) String spPrivateKeyAlias, @ApiParam(value = "") @RequestParam(value = "spPrivateKeyAlias@TypeHint", required = false) String spPrivateKeyAliasAtTypeHint, @ApiParam(value = "") @RequestParam(value = "useEncryption", required = false) Boolean useEncryption, @ApiParam(value = "") @RequestParam(value = "useEncryption@TypeHint", required = false) String useEncryptionAtTypeHint, @ApiParam(value = "") @RequestParam(value = "nameIdFormat", required = false) String nameIdFormat, @ApiParam(value = "") @RequestParam(value = "nameIdFormat@TypeHint", required = false) String nameIdFormatAtTypeHint, @ApiParam(value = "") @RequestParam(value = "digestMethod", required = false) String digestMethod, @ApiParam(value = "") @RequestParam(value = "digestMethod@TypeHint", required = false) String digestMethodAtTypeHint, @ApiParam(value = "") @RequestParam(value = "signatureMethod", required = false) String signatureMethod, @ApiParam(value = "") @RequestParam(value = "signatureMethod@TypeHint", required = false) String signatureMethodAtTypeHint, @ApiParam(value = "") @RequestParam(value = "userIntermediatePath", required = false) String userIntermediatePath, @ApiParam(value = "") @RequestParam(value = "userIntermediatePath@TypeHint", required = false) String userIntermediatePathAtTypeHint, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity<Void>(HttpStatus.OK); }
Example 16
Source File: WorkflowController.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
@PostMapping("/loadStatistics.action") public ResponseEntity<Map<Integer, List<String>>> loadStatistics(ComAdmin admin, @RequestParam int workflowId) { Map<Integer, List<String>> stats = workflowStatisticsService.getWorkflowStats(workflowId, admin.getCompanyID(), admin.getLocale()); return new ResponseEntity<>(stats, HttpStatus.OK); }
Example 17
Source File: PersonApiController.java From Java-9-Cookbook with MIT License | 4 votes |
@PostMapping("/{id}") public ResponseEntity<Person> updatePerson(@RequestBody Person person, @PathVariable Integer id){ person.setId(id); personMapper.save(person); return new ResponseEntity<>(person, HttpStatus.OK); }
Example 18
Source File: CrxApiController.java From swagger-aem with Apache License 2.0 | 4 votes |
public ResponseEntity<String> postPackageService(@ApiParam(value = "", required = true) @RequestParam(value = "cmd", required = true) String cmd, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity<String>(HttpStatus.OK); }
Example 19
Source File: AddStaffServiceListener.java From MicroCommunity with Apache License 2.0 | 4 votes |
@Override protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { //获取数据上下文对象 Assert.jsonObjectHaveKey(reqJson, "storeId", "请求参数中未包含storeId 节点,请确认"); Assert.jsonObjectHaveKey(reqJson, "storeTypeCd", "请求参数中未包含storeTypeCd 节点,请确认"); //判断请求报文中包含 userId 并且 不为-1时 将已有用户添加为员工,反之,则添加用户再将用户添加为员工 String userId = ""; String oldUserId = ""; String relCd = reqJson.getString("relCd");//员工 组织 岗位 if (!reqJson.containsKey("userId") || "-1".equals(reqJson.getString("userId"))) { //将userId 强制写成-1 oldUserId = "-1"; userId = GenerateCodeFactory.getUserId(); reqJson.put("userId", userId); //添加用户 userBMOImpl.addUser(reqJson, context); } reqJson.put("userId", userId); reqJson.put("relCd", "-1".equals(oldUserId) ? StoreUserRelConstant.REL_COMMON : StoreUserRelConstant.REL_ADMIN); userBMOImpl.addStaff(reqJson, context); //重写 员工岗位 reqJson.put("relCd", relCd); userBMOImpl.addStaffOrg(reqJson, context); if (reqJson.containsKey("photo") && !StringUtils.isEmpty(reqJson.getString("photo"))) { FileDto fileDto = new FileDto(); fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id)); fileDto.setFileName(fileDto.getFileId()); fileDto.setContext(reqJson.getString("photo")); fileDto.setSuffix("jpeg"); fileDto.setCommunityId(reqJson.getString("communityId")); String fileName = fileInnerServiceSMOImpl.saveFile(fileDto); reqJson.put("photoId", fileDto.getFileId()); reqJson.put("fileSaveName", fileName); JSONObject businessUnit = new JSONObject(); businessUnit.put("fileRelId", "-1"); businessUnit.put("relTypeCd", "12000"); businessUnit.put("saveWay", "table"); businessUnit.put("objId", userId); businessUnit.put("fileRealName", fileDto.getFileId()); businessUnit.put("fileSaveName", fileName); FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class); super.insert(context, fileRelPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FILE_REL); } commit(context); //如果不成功直接返回 if (context.getResponseEntity().getStatusCode() != HttpStatus.OK) { return; } //赋权 privilegeUserDefault(context, reqJson); }
Example 20
Source File: APIServiceStatusService.java From api-layer with Eclipse Public License 2.0 | 2 votes |
/** * Return the cached API docs for a service * * @param serviceId the unique service id * @param apiVersion the version of the API * @return a version of an API Doc */ public ResponseEntity<String> getServiceCachedApiDocInfo(@NonNull String serviceId, String apiVersion) { return new ResponseEntity<>(cachedApiDocService.getApiDocForService(serviceId, apiVersion), createHeaders(), HttpStatus.OK); }