Java Code Examples for org.springframework.http.ResponseEntity#ok()
The following examples show how to use
org.springframework.http.ResponseEntity#ok() .
These examples are extracted from open source projects.
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 Project: XS2A-Sandbox File: SCAController.java License: Apache License 2.0 | 6 votes |
@Override public ResponseEntity<AuthorizeResponse> validateAuthCode(String scaId, String authorisationId, String authCode, String cookies) { // build response AuthorizeResponse authResponse = new AuthorizeResponse(); authResponse.setEncryptedConsentId(scaId); authResponse.setAuthorisationId(authorisationId); try { authInterceptor.setAccessToken(auth.getBearerToken().getAccess_token()); SCALoginResponseTO authorizeResponse = ledgersUserMgmt.authorizeLogin(scaId, authorisationId, authCode).getBody(); prepareAuthResponse(authResponse, Objects.requireNonNull(authorizeResponse)); BearerTokenTO bearerToken = authorizeResponse.getBearerToken(); responseUtils.setCookies(response, null, bearerToken.getAccess_token(), bearerToken.getAccessTokenObject()); return ResponseEntity.ok(authResponse); } finally { authInterceptor.setAccessToken(null); } }
Example 2
Source Project: taskana File: TaskController.java License: Apache License 2.0 | 6 votes |
@GetMapping(path = Mapping.URL_TASKS) @Transactional(readOnly = true, rollbackFor = Exception.class) public ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> getTasks( @RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Entry to getTasks(params= {})", params); } TaskQuery query = taskService.createTaskQuery(); query = applyFilterParams(query, params); query = applySortingParams(query, params); PageMetadata pageMetadata = getPageMetadata(params, query); List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata); TaskanaPagedModel<TaskSummaryRepresentationModel> pagedModels = taskSummaryRepresentationModelAssembler.toPageModel(taskSummaries, pageMetadata); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response = ResponseEntity.ok(pagedModels); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Exit from getTasks(), returning {}", response); } return response; }
Example 3
Source Project: ponto-inteligente-api File: LancamentoController.java License: MIT License | 6 votes |
/** * Remove um lançamento por ID. * * @param id * @return ResponseEntity<Response<Lancamento>> */ @DeleteMapping(value = "/{id}") @PreAuthorize("hasAnyRole('ADMIN')") public ResponseEntity<Response<String>> remover(@PathVariable("id") Long id) { log.info("Removendo lançamento: {}", id); Response<String> response = new Response<String>(); Optional<Lancamento> lancamento = this.lancamentoService.buscarPorId(id); if (!lancamento.isPresent()) { log.info("Erro ao remover devido ao lançamento ID: {} ser inválido.", id); response.getErrors().add("Erro ao remover lançamento. Registro não encontrado para o id " + id); return ResponseEntity.badRequest().body(response); } this.lancamentoService.remover(id); return ResponseEntity.ok(new Response<String>()); }
Example 4
Source Project: hawkbit File: MgmtTargetResource.java License: Eclipse Public License 1.0 | 5 votes |
@Override public ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("targetId") final String targetId, @PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadataBodyPut metadata) { final TargetMetadata updated = targetManagement.updateMetadata(targetId, entityFactory.generateTargetMetadata(metadataKey, metadata.getValue())); return ResponseEntity.ok(MgmtTargetMapper.toResponseTargetMetadata(updated)); }
Example 5
Source Project: spring-batch-lightmin File: JobRestController.java License: Apache License 2.0 | 5 votes |
/** * Retrieves high level {@link ApplicationJobInfo} of the Application * * @return the ApplicationJobInfo */ @GetMapping( value = JobRestControllerAPI.APPLICATION_JOB_INFO, produces = PRODUCES) public ResponseEntity<ApplicationJobInfo> getApplicationJobInfo() { final ApplicationJobInfo applicationJobInfo = this.serviceEntry.getApplicationJobInfo(); return ResponseEntity.ok(applicationJobInfo); }
Example 6
Source Project: alf.io File: ReservationApiV2Controller.java License: GNU General Public License v3.0 | 5 votes |
@DeleteMapping("/event/{eventName}/reservation/{reservationId}") public ResponseEntity<Boolean> cancelPendingReservation(@PathVariable("eventName") String eventName, @PathVariable("reservationId") String reservationId) { getReservationWithPendingStatus(eventName, reservationId) .ifPresent(er -> ticketReservationManager.cancelPendingReservation(reservationId, false, null)); return ResponseEntity.ok(true); }
Example 7
Source Project: chatbot File: FBHandler.java License: Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<String> verifyWebHook(@RequestParam(MessengerPlatform.MODE_REQUEST_PARAM_NAME) final String mode, @RequestParam(MessengerPlatform.VERIFY_TOKEN_REQUEST_PARAM_NAME) final String verifyToken, @RequestParam(MessengerPlatform.CHALLENGE_REQUEST_PARAM_NAME) final String challenge) { logger.debug("Received Webhook verification request - mode: {} | verifyToken: {} | challenge: {}", mode, verifyToken, challenge); try { return ResponseEntity.ok(this.receiveClient.verifyWebhook(mode, verifyToken, challenge)); } catch (MessengerVerificationException e) { logger.warn("Webhook verification failed: {}", e.getMessage()); return ResponseEntity.status(HttpStatus.FORBIDDEN).body(e.getMessage()); } }
Example 8
Source Project: hawkbit File: MgmtDistributionSetTypeResource.java License: Eclipse Public License 1.0 | 5 votes |
@Override public ResponseEntity<MgmtSoftwareModuleType> getMandatoryModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); final SoftwareModuleType foundSmType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); if (!foundType.containsMandatoryModuleType(foundSmType)) { throw new SoftwareModuleTypeNotInDistributionSetTypeException(softwareModuleTypeId, distributionSetTypeId); } return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toResponse(foundSmType)); }
Example 9
Source Project: library File: PatronProfileController.java License: MIT License | 5 votes |
@GetMapping("/profiles/{patronId}/holds/") ResponseEntity<CollectionModel<EntityModel<Hold>>> findHolds(@PathVariable UUID patronId) { List<EntityModel<Hold>> holds = patronProfiles.fetchFor(new PatronId(patronId)) .getHoldsView() .getCurrentHolds() .toStream() .map(hold -> resourceWithLinkToHoldSelf(patronId, hold)) .collect(toList()); return ResponseEntity.ok(new CollectionModel<>(holds, linkTo(methodOn(PatronProfileController.class).findHolds(patronId)).withSelfRel())); }
Example 10
Source Project: taskana File: TaskanaEngineController.java License: Apache License 2.0 | 5 votes |
@GetMapping(path = Mapping.URL_CLASSIFICATION_TYPES) public ResponseEntity<List<String>> getClassificationTypes() { ResponseEntity<List<String>> response = ResponseEntity.ok(taskanaEngineConfiguration.getClassificationTypes()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Exit from getClassificationTypes(), returning {}", response); } return response; }
Example 11
Source Project: alf.io File: EventApiV1Controller.java License: GNU General Public License v3.0 | 5 votes |
@PostMapping("/create") @Transactional public ResponseEntity<String> create(@RequestBody EventCreationRequest request, Principal user) { String imageRef = Optional.ofNullable(request.getImageUrl()).map(this::fetchImage).orElse(null); Organization organization = userManager.findUserOrganizations(user.getName()).get(0); AtomicReference<Errors> errorsContainer = new AtomicReference<>(); Result<String> result = new Result.Builder<String>() .checkPrecondition(() -> isNotBlank(request.getTitle()), ErrorCode.custom("invalid.title", "Invalid title")) .checkPrecondition(() -> isBlank(request.getSlug()) || eventNameManager.isUnique(request.getSlug()), ErrorCode.custom("invalid.slug", "Invalid slug")) .checkPrecondition(() -> isNotBlank(request.getWebsiteUrl()), ErrorCode.custom("invalid.websiteUrl", "Invalid Website URL")) .checkPrecondition(() -> isNotBlank(request.getTermsAndConditionsUrl()), ErrorCode.custom("invalid.tc", "Invalid Terms and Conditions")) .checkPrecondition(() -> isNotBlank(request.getImageUrl()), ErrorCode.custom("invalid.imageUrl", "Invalid Image URL")) .checkPrecondition(() -> isNotBlank(request.getTimezone()), ErrorCode.custom("invalid.timezone", "Invalid Timezone")) .checkPrecondition(() -> isNotBlank(imageRef), ErrorCode.custom("invalid.image", "Image is either missing or too big (max 200kb)")) .checkPrecondition(() -> { EventModification eventModification = request.toEventModification(organization, eventNameManager::generateShortName, imageRef); errorsContainer.set(new BeanPropertyBindingResult(eventModification, "event")); ValidationResult validationResult = validateEvent(eventModification, errorsContainer.get()); if(!validationResult.isSuccess()) { log.warn("validation failed {}", validationResult.getValidationErrors()); } return validationResult.isSuccess(); }, ErrorCode.lazy(() -> toErrorCode(errorsContainer.get()))) //TODO all location validation //TODO language validation, for all the description the same languages .build(() -> insertEvent(request, user, imageRef).map(Event::getShortName).orElseThrow(IllegalStateException::new)); if(result.isSuccess()) { return ResponseEntity.ok(result.getData()); } else { return ResponseEntity.badRequest().body(Json.toJson(result.getErrors())); } }
Example 12
Source Project: servicecomb-saga-actuator File: MembershipController.java License: Apache License 2.0 | 5 votes |
@RequestMapping(value = "membership", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) public ResponseEntity<String> levelUp(@RequestParam String customerId) { if (!customers.contains(customerId)) { return new ResponseEntity<>("No such customer with id " + customerId, FORBIDDEN); } return ResponseEntity.ok(String.format("{\n" + " \"body\": \"Level up customer %s to silver member\"\n" + "}", customerId)); }
Example 13
Source Project: hawkbit File: MgmtSoftwareModuleResource.java License: Eclipse Public License 1.0 | 5 votes |
@Override public ResponseEntity<MgmtSoftwareModule> updateSoftwareModule( @PathVariable("softwareModuleId") final Long softwareModuleId, @RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) { final SoftwareModule module = softwareModuleManagement .update(entityFactory.softwareModule().update(softwareModuleId) .description(restSoftwareModule.getDescription()).vendor(restSoftwareModule.getVendor())); final MgmtSoftwareModule response = MgmtSoftwareModuleMapper.toResponse(module); MgmtSoftwareModuleMapper.addLinks(module, response); return ResponseEntity.ok(response); }
Example 14
Source Project: spring-cloud-zuul-ratelimit File: Bucket4jHazelcastApplication.java License: Apache License 2.0 | 4 votes |
@GetMapping("/serviceD/{paramName}") public ResponseEntity<String> serviceD(@PathVariable String paramName) { return ResponseEntity.ok(RESPONSE_BODY + " " + paramName); }
Example 15
Source Project: microservice-app File: AccountApi.java License: GNU General Public License v3.0 | 4 votes |
@GetMapping("/{id}") public ResponseEntity<AccountDto> get(@PathVariable("id") String id) { return ResponseEntity.ok(accountService.get(id)); }
Example 16
Source Project: sureness File: SimulateController.java License: Apache License 2.0 | 4 votes |
@PatchMapping("/api/v1/source2") public ResponseEntity<Map<String, String>> api1Mock10(HttpServletRequest request) { return ResponseEntity.ok(getResponseMap(request)); }
Example 17
Source Project: sureness File: SimulateController.java License: Apache License 2.0 | 4 votes |
@GetMapping("/api/v1/source3") public ResponseEntity<Map<String, String>> api1Mock11(HttpServletRequest request) { return ResponseEntity.ok(getResponseMap(request)); }
Example 18
Source Project: spring-boot-microservice-eureka-zuul-docker File: OrderResource.java License: MIT License | 4 votes |
@GetMapping() public ResponseEntity<Collection<Order>> getAll() { return ResponseEntity.ok(repository.findAll().get()); }
Example 19
Source Project: Learning-Path-Spring-5-End-to-End-Programming File: NewsResource.java License: MIT License | 4 votes |
@GetMapping(value = "/revised") public ResponseEntity<List<News>> revisedNews(){ return ResponseEntity.ok(Arrays.asList(new News(),new News())); }
Example 20
Source Project: gem File: GemPermissionsController.java License: MIT License | 2 votes |
/** * @Description: 根据角色和菜单获取权限-按钮(仅仅包含选中的) * @param roleId 角色主键 * @param permissionId 权限(菜单)主键 * @author: Ryan * @date 2018年11月5日 */ @PostMapping("permission/findPermissionOnlySelectByRoleIdAndPermissionId") public ResponseEntity<ResultData> findPermissionOnlySelectByRoleIdAndPermissionId(Long roleId,Long permissionId) { List<GemPermissions> permissionList = permissionsService.findPermissionOnlySelectByRoleIdAndPermissionId(roleId,permissionId); return ResponseEntity.ok(ResultData.SUCCESS(permissionList)); }