List of usage examples for org.springframework.http ResponseEntity ok
public static <T> ResponseEntity<T> ok(T body)
From source file:com.oembedler.moon.graphql.boot.GraphQLServerController.java
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> getJson(@RequestParam(DEFAULT_QUERY_KEY) String query, @RequestParam(value = DEFAULT_VARIABLES_KEY, required = false) String variables, @RequestParam(value = DEFAULT_OPERATION_NAME_KEY, required = false) String operationName, @RequestHeader(value = HEADER_SCHEMA_NAME, required = false) String graphQLSchemaName, HttpServletRequest httpServletRequest) throws IOException { final GraphQLContext graphQLContext = new GraphQLContext(); graphQLContext.setHttpRequest(httpServletRequest); final Map<String, Object> result = evaluateAndBuildResponseMap(query, operationName, graphQLContext, decodeIntoMap(variables), graphQLSchemaName); return ResponseEntity.ok(result); }
From source file:de.dominikschadow.configclient.secret.SecretController.java
/** * Returns the secrets stored at the configured base path. * * @return The loaded secrets from vault *///from w w w. j a v a2s . c om @GetMapping(value = "/secrets", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Returns a list of secret stored in the vault at the configured base path", response = String.class, responseContainer = "List") public ResponseEntity<List<String>> listSecrets() { List<String> secrets = vaultTemplate.list(SECRET_BASE_PATH); return ResponseEntity.ok(secrets); }
From source file:blankd.acme.pet.licensing.rest.controller.LicenseRestController.java
@RequestMapping(value = "/new", method = RequestMethod.POST) public ResponseEntity<?> addNewLicense(@RequestParam(required = false) String license) { License ret = this.repo.save(new License(license)); if (ret != null) { return ResponseEntity.ok(ret); } else {// w w w .j a va2 s. co m ErrorMessage err = new ErrorMessage("Could not create new License"); return ResponseEntity.ok(err); } }
From source file:de.codecentric.boot.admin.registry.web.RegistryController.java
/** * Unregister an application within this admin application. * * @param id The application id.//from w w w. ja v a 2 s. co m * @return the unregistered application. */ @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.DELETE) public ResponseEntity<?> unregister(@PathVariable String id) { LOGGER.debug("Unregister application with ID '{}'", id); Application application = registry.deregister(id); if (application != null) { return ResponseEntity.ok(application); } else { return ResponseEntity.notFound().build(); } }
From source file:io.ignitr.dispatchr.manager.controller.topic.TopicsController.java
/** * Find all available SNS topics within the AWS account and whether or not they are registered with Dispatchr. * * @param offset index of item to start returning when using pagination * @param limit number of items to return when using pagination * @param sortDir sort order in which to return items when using pagination * @return an HTTP 200 response if the request was successful *///from ww w . j a va 2s.com @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public DeferredResult<ResponseEntity<FindTopicsResponse>> findAll( @RequestParam(value = "offset", defaultValue = "0") Long offset, @RequestParam(value = "limit", defaultValue = "25") Long limit, @RequestParam(value = "sort_dir", defaultValue = "asc") String sortDir, HttpServletRequest httpRequest) { final DeferredResult<ResponseEntity<FindTopicsResponse>> deferredResult = new DeferredResult<>(); Observable.fromCallable(() -> SortDirectionValidator.validate(sortDir)) .lift(new RequestContextStashOperator<>()) .flatMap(valid -> Observable.create(new Observable.OnSubscribe<List<Topic>>() { List<Topic> topicMetadatas = new ArrayList<>(); @Override public void call(Subscriber<? super List<Topic>> subscriber) { service.findAll(offset, limit, sortDir).collect(() -> topicMetadatas, List::add) .subscribe(topicMetadatas -> { subscriber.onNext(topicMetadatas); subscriber.onCompleted(); }); } })).map(FindTopicsResponse::from).subscribeOn(Schedulers.io()).subscribe(body -> { deferredResult.setResult(ResponseEntity.ok(body)); }, error -> { deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error)); }); return deferredResult; }
From source file:io.curly.tagger.TagControllerTests.java
@Test public void testGet() throws Exception { mockMvc.perform(asyncDispatch(/* w w w.j a v a2 s .co m*/ mockMvc.perform(get(withControllerPath("/{tag}"), "love")).andExpect(request().asyncStarted()) .andExpect(request().asyncResult(ResponseEntity.ok(tag))).andReturn())); //.andExpect(content().contentType(jsonMediaType())) //.andExpect(content().json(json(tag, new MappingJackson2HttpMessageConverter()))); }
From source file:alfio.controller.api.admin.ExtensionApiController.java
private ResponseEntity<SerializablePair<Boolean, String>> createOrUpdate(String previousPath, String previousName, Extension script, Principal principal) { try {/* ww w .j av a2 s .co m*/ ensureAdmin(principal); extensionService.createOrUpdate(previousPath, previousName, script); return ResponseEntity.ok(SerializablePair.of(true, null)); } catch (Throwable t) { return ResponseEntity.badRequest().body(SerializablePair.of(false, t.getMessage())); } }
From source file:org.icgc.dcc.metadata.server.resource.EntityResource.java
@RequestMapping(value = "/{id}", method = HEAD) public ResponseEntity<?> exists(@PathVariable("id") String id) { val exists = repository.exists(id); if (!exists) { return new ResponseEntity<>(NOT_FOUND); }/*from w w w. j a va 2s . c o m*/ return ResponseEntity.ok(null); }
From source file:com.github.ukase.web.UkaseController.java
@RequestMapping(value = "/html", method = RequestMethod.POST) public ResponseEntity<String> generateHtml(@RequestBody @Valid UkasePayload payload) throws IOException { String result = htmlRenderer.render(payload.getIndex(), payload.getData()); return ResponseEntity.ok(result); }
From source file:com.fns.grivet.controller.NamedQueryController.java
@PreAuthorize("hasAuthority('list:query')") @GetMapping("/api/v1/queries") public ResponseEntity<?> listNamedQueries() { JSONArray payload = namedQueryService.all(); return ResponseEntity.ok(payload.toString()); }