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.n52.restfulwpsproxy.webapp.rest.JobController.java

@RequestMapping(value = "/{jobId:.+}", method = RequestMethod.GET)
public ResponseEntity<StatusInfoWrapperWithOutput> getStatus(@PathVariable("processId") String processId,
        @PathVariable("jobId") String jobId, HttpServletRequest request) {
    StatusInfoDocument statusInfo = client.getStatusInfo(processId, jobId);
    return ResponseEntity.ok(new WPSStatusJsonModule.StatusInfoWrapperWithOutput(
            request.getRequestURL().toString(), statusInfo));
}

From source file:com.orange.clara.tool.controllers.RssController.java

@RequestMapping(method = RequestMethod.GET, value = "/{id:[0-9]+}*")
public @ResponseBody ResponseEntity<String> getFeed(@PathVariable("id") Integer id) throws FeedException {
    User user = this.getCurrentUser();
    WatchedResource watchedResource = this.watchedResourceRepo.findOne(id);
    if (watchedResource == null) {
        return generateEntityFromStatus(HttpStatus.NOT_FOUND);
    }//  ww w .  java2  s  .c  om
    if (!watchedResource.hasUser(user) && !this.isCurrentUserAdmin()) {
        return generateEntityFromStatus(HttpStatus.UNAUTHORIZED);
    }
    SyndFeed feed = rssService.generateFeed(watchedResource);
    return ResponseEntity.ok(rssService.getOutput(feed));
}

From source file:de.codecentric.boot.admin.registry.StatusUpdaterTest.java

@Test
@SuppressWarnings("rawtypes")
public void test_update_statusUnchanged() {
    when(template.getForEntity("health", Map.class))
            .thenReturn(ResponseEntity.ok((Map) Collections.singletonMap("status", "UNKNOWN")));

    updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build());

    verify(publisher, never()).publishEvent(argThat(isA(ClientApplicationStatusChangedEvent.class)));
}

From source file:io.ignitr.dispatchr.manager.controller.subscription.SubscriptionsController.java

/**
 *
 * @param topicName/*from w  w w. j  a  v  a2 s  .c om*/
 * @param httpRequest
 * @return
 */
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public DeferredResult<ResponseEntity<FindSubscriptionsResponse>> findAll(@PathVariable("name") String topicName,
        HttpServletRequest httpRequest) {
    final DeferredResult<ResponseEntity<FindSubscriptionsResponse>> deferredResult = new DeferredResult<>();

    topicService.findOne(topicName).lift(new RequestContextStashOperator<>()).flatMap(topicMetadata -> {
        List<Subscription> subscriptionMetadatas = new ArrayList<>();

        return subscriptionService.findAll(topicMetadata.getName()).collect(() -> subscriptionMetadatas,
                List::add);
    }).map(FindSubscriptionsResponse::from).subscribeOn(Schedulers.io()).subscribe(body -> {
        deferredResult.setResult(ResponseEntity.ok(body));
    }, error -> {
        deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error));
    });

    return deferredResult;
}

From source file:org.n52.restfulwpsproxy.webapp.rest.ProcessController.java

@RequestMapping(value = "/{processId:.+}", method = RequestMethod.GET)
public ResponseEntity<ProcessOfferings> describeProcess(@PathVariable("processId") String processId,
        HttpServletRequest request) throws URISyntaxException {
    return ResponseEntity.ok(processesClient.getProcessDescription(processId).getProcessOfferings());
}

From source file:com.orange.clara.pivotaltrackermirror.controllers.TaskStatusController.java

@ApiOperation(value = "Get information of all tasks.", response = TriggerResponse.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, value = "/", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAll() throws SchedulerException {
    Iterable<MirrorReference> mirrorReferences = this.mirrorReferenceRepo.findAll();
    List<TriggerResponse> triggerResponseList = Lists.newArrayList();
    for (MirrorReference mirrorReference : mirrorReferences) {
        Trigger trigger = this.getTriggerFromId(mirrorReference.getId());
        triggerResponseList.add(new TriggerResponse(trigger, this.getTriggerState(mirrorReference.getId()),
                mirrorReference.getId()));
    }/*from www . j  a  v  a  2s . c o  m*/
    return ResponseEntity.ok(triggerResponseList);
}

From source file:com.anuz.dummyapi.controller.ClientController.java

@RequestMapping(value = "delete/{id}", method = RequestMethod.GET)
public ResponseEntity delete(@PathVariable("id") int id) {
    clientService.delete(id);/*from   ww  w  .  j  a va  2  s  .co  m*/
    return ResponseEntity.ok(id);
}

From source file:com.jevontech.wabl.controllers.AuthenticationController.java

@CrossOrigin
//@RequestMapping("/auth")
@RequestMapping(value = "/auth", method = RequestMethod.POST)
public ResponseEntity<?> authenticationRequest(@RequestBody AuthenticationRequest authenticationRequest,
        Device device) throws AuthenticationException {

    // Perform the authentication
    Authentication authentication = this.authenticationManager
            .authenticate(new UsernamePasswordAuthenticationToken(authenticationRequest.getUsername(),
                    authenticationRequest.getPassword()));
    SecurityContextHolder.getContext().setAuthentication(authentication);

    // Reload password post-authentication so we can generate token
    UserDetails userDetails = this.userDetailsService.loadUserByUsername(authenticationRequest.getUsername());
    String token = this.tokenUtils.generateToken(userDetails, device);

    // Return the token
    return ResponseEntity.ok(new AuthenticationResponse(token));
}

From source file:io.ignitr.dispatchr.manager.controller.topic.TopicController.java

/**
 * Get the metadata for a specific topic.
 *
 * @param topicName the name of the topic for which to retrieve metadata
 * @return an HTTP 200 response if the request was successful
 *///  w w w . j  a va 2  s .  c  o m
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public DeferredResult<ResponseEntity<FindTopicResponse>> findOne(@PathVariable("name") String topicName,
        HttpServletRequest httpRequest) {
    final DeferredResult<ResponseEntity<FindTopicResponse>> deferredResult = new DeferredResult<>();

    service.findOne(topicName).lift(new RequestContextStashOperator<>()).last().map(topicMetadata -> {
        if (topicMetadata == null) {
            throw new TopicNotFoundException(topicName);
        }

        return topicMetadata;
    }).map(FindTopicResponse::from).subscribeOn(Schedulers.io()).subscribe(body -> {
        deferredResult.setResult(ResponseEntity.ok(body));
    }, error -> {
        deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error));
    });

    return deferredResult;
}

From source file:org.createnet.raptor.auth.service.controller.UserController.java

@PreAuthorize("hasAuthority('admin') or hasAuthority('super_admin')")
@RequestMapping(value = { "/user" }, method = RequestMethod.POST)
@ApiOperation(value = "Create a new user", notes = "", response = User.class, nickname = "createUser")
public ResponseEntity<User> create(
        @AuthenticationPrincipal RaptorUserDetailsService.RaptorUserDetails currentUser,
        @RequestBody User rawUser) {/*from   ww w  . java2  s  . c o m*/

    boolean exists = userService.exists(rawUser);

    if (exists) {
        return ResponseEntity.status(403).body(null);
    }

    return ResponseEntity.ok(userService.create(rawUser));
}