Example usage for org.springframework.http ResponseEntity ok

List of usage examples for org.springframework.http ResponseEntity ok

Introduction

In this page you can find the example usage for org.springframework.http ResponseEntity ok.

Prototype

public static <T> ResponseEntity<T> ok(T body) 

Source Link

Document

A shortcut for creating a ResponseEntity with the given body and the status set to HttpStatus#OK OK .

Usage

From source file:org.apache.ambari.view.web.controller.RepositoryController.java

@PostMapping("/{id}/action")
public ResponseEntity<Map<String, String>> start(@PathVariable("id") Long id,
        @RequestBody RepositoryWrapper.ActionRequest request) {
    repositoryService.start(id, request);
    Map<String, String> emptyMap = new HashMap<>();
    return ResponseEntity.ok(emptyMap);
}

From source file:tds.assessment.web.endpoints.AssessmentWindowController.java

@GetMapping(value = "{clientName}/assessments/{assessmentId}/windows", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody//from   ww w  . j a va 2  s.co m
ResponseEntity<List<AssessmentWindow>> findAssessmentWindows(@PathVariable final String clientName,
        @PathVariable final String assessmentId, @RequestParam final boolean guestStudent,
        @RequestParam(required = false) final Integer shiftWindowStart,
        @RequestParam(required = false) final Integer shiftWindowEnd,
        @RequestParam(required = false) final Integer shiftFormStart,
        @RequestParam(required = false) final Integer shiftFormEnd,
        @RequestParam(required = false) final String formList) {
    AssessmentWindowParameters assessmentWindowParameters = new AssessmentWindowParameters.Builder(guestStudent,
            clientName, assessmentId).withShiftWindowStart(shiftWindowStart == null ? 0 : shiftWindowStart)
                    .withShiftWindowEnd(shiftWindowEnd == null ? 0 : shiftWindowEnd)
                    .withShiftFormStart(shiftFormStart == null ? 0 : shiftFormStart)
                    .withShiftFormEnd(shiftFormEnd == null ? 0 : shiftFormEnd).withFormList(formList).build();

    return ResponseEntity.ok(assessmentWindowService.findAssessmentWindows(assessmentWindowParameters));
}

From source file:de.msg.controller.RouteController.java

@RequestMapping
@PreAuthorize("isAuthenticated() and hasPermission('de.msg.domain.route.Route', 'read')")
public ResponseEntity<Iterable<Route>> findAll() {
    return ResponseEntity.ok(service.findAll());
}

From source file:org.icgc.dcc.metadata.server.resource.EntityResource.java

@RequestMapping("/{id}")
public ResponseEntity<Entity> get(@PathVariable("id") String id) {
    val entity = repository.findOne(id);

    if (entity == null) {
        return new ResponseEntity<Entity>(NOT_FOUND);
    }//from   w  w  w .  j a  v  a  2 s  .  com

    return ResponseEntity.ok(entity);
}

From source file:de.codecentric.boot.admin.notify.filter.web.NotificationFilterController.java

@RequestMapping(path = "/api/notifications/filters/{id}", method = { RequestMethod.DELETE })
public ResponseEntity<?> deleteFilter(@PathVariable("id") String id) {
    NotificationFilter deleted = filteringNotifier.removeFilter(id);
    if (deleted != null) {
        return ResponseEntity.ok(deleted);
    } else {/*from  w  ww  .j  ava  2 s  . co  m*/
        return ResponseEntity.notFound().build();
    }
}

From source file:curly.artifactory.ArtifactResourceControllerTests.java

@Test
public void testArtifactResource() throws Exception {
    String id = artifact.getId();
    mockMvc.perform(asyncDispatch(mockMvc.perform(get("/arts/{id}", id)).andExpect(status().isOk())
            .andExpect(request().asyncStarted()).andExpect(request().asyncResult(ResponseEntity.ok(artifact)))
            .andReturn())).andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andExpect(content().json(json(artifact, messageConverter)));
}

From source file:alfio.controller.api.AttendeeApiController.java

@RequestMapping(value = "/sponsor-scan/bulk", method = RequestMethod.POST)
public ResponseEntity<List<TicketAndCheckInResult>> scanBadges(@RequestBody List<SponsorScanRequest> requests,
        Principal principal) {//from   w ww  . j a  va 2  s  .c o  m
    String username = principal.getName();
    return ResponseEntity
            .ok(requests.stream().map(request -> attendeeManager.registerSponsorScan(request.eventName,
                    request.ticketIdentifier, username)).collect(Collectors.toList()));
}

From source file:com.orange.clara.tool.controllers.api.WatchedResourcesController.java

@RequestMapping(method = RequestMethod.POST, value = "")
public @ResponseBody ResponseEntity<?> register(@RequestBody WatchedResource watchedResource)
        throws CrawlerGetContentException {
    User user = this.getCurrentUser();
    watchedResource.setLocked(true);/* w  ww  . ja v a2s  .c  o m*/
    watchedResource.addUser(user);
    Crawler crawler = this.crawlerFactory.findCrawler(watchedResource.getType());
    this.createOrLinkTag(watchedResource);
    watchedResource.setTitle(crawler.generateTitle(watchedResource));
    watchedResource.setImage(crawler.getImage(watchedResource));
    watchedResource = this.watchedResourceRepo.save(watchedResource);
    List<ContentResource> contentResources = crawler.getLastContent(watchedResource);
    for (ContentResource contentResource : contentResources) {
        watchedResource.addContentResource(contentResource);
        this.contentResourceRepo.save(contentResource);
    }
    watchedResource.setUpdatedResourceAt(Calendar.getInstance().getTime());
    watchedResource.setLocked(false);
    watchedResource = this.watchedResourceRepo.save(watchedResource);
    return ResponseEntity.ok(this.generateResource(watchedResource));
}

From source file:com.github.lynxdb.server.api.http.handlers.EpUser.java

@RequestMapping(value = "", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity createUser(Authentication _authentication, @RequestBody @Valid UserCreationRequest _ucr,
        BindingResult _bindingResult) {/* w w  w.  j a  va  2 s.  co  m*/

    if (_bindingResult.hasErrors()) {
        ArrayList<String> errors = new ArrayList();
        _bindingResult.getFieldErrors().forEach((FieldError t) -> {
            errors.add(t.getField() + ": " + t.getDefaultMessage());
        });
        return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, errors.toString()).response();
    }

    User u = new User(_ucr);

    if (users.create(u)) {
        return ResponseEntity.ok(u);
    } else {
        return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, "User already exists").response();
    }
}

From source file:de.dominikschadow.configclient.secret.SecretController.java

/**
 * Returns the complete secret identified by the given user id. Returned data can be limited to the secrets content
 * by specifying the value secret for the query param type.
 *
 * @param userId The user id to load the secret for
 * @param type   The return type, empty for all, secret for the secret only
 * @return The loaded secret from vault/*from   w  w w  . jav  a  2 s. c o  m*/
 */
@GetMapping(value = "/secrets/{userId}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns the secret stored for the given user id", notes = "Returned data can be limited to the secrets content by specifying the value secret for the query param type.", response = Object.class)
public ResponseEntity<Object> readSecret(@PathVariable String userId,
        @RequestParam(value = "type", required = false) String type) {
    VaultResponse secret = vaultTemplate.read(SECRET_BASE_PATH + userId);

    if ("secret".equals(type)) {
        return ResponseEntity.ok(secret.getData());
    } else {
        return ResponseEntity.ok(secret);
    }
}