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:com.greglturnquist.springagram.fileservice.mongodb.ApplicationController.java

@RequestMapping(method = RequestMethod.GET, value = "/files")
public ResponseEntity<ResourceSupport> listAllFiles() {

    ResourceSupport files = new ResourceSupport();

    for (GridFsResource resource : this.fileService.findAll()) {
        files.add(linkTo(methodOn(ApplicationController.class).getFile(resource.getFilename()))
                .withRel(resource.getFilename()));
    }//from ww  w.ja  va  2  s  . c  o  m

    return ResponseEntity.ok(files);
}

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

@RequestMapping(value = "/{jobId:.+}/outputs", method = RequestMethod.GET)
public ResponseEntity<ResultDocument> getOutputs(@PathVariable("processId") String processId,
        @PathVariable("jobId") String jobId, HttpServletRequest request) {
    return ResponseEntity.ok(client.getResults(processId, jobId));
}

From source file:org.n52.tamis.rest.controller.processes.ProcessesController.java

/**
 * //from  w ww.  ja va2  s . c o  m
 * Returns the shortened processes overview document.
 * 
 * @param serviceID
 *            inside the URL the variable
 *            {@link URL_Constants_TAMIS#SERVICE_ID_VARIABLE_NAME} specifies
 *            the id of the service. * @param request
 * @return shortened processes overview document
 */
@RequestMapping("")
@ResponseBody
public ResponseEntity<Processes_Tamis> getProcessesOverview(
        @PathVariable(URL_Constants_TAMIS.SERVICE_ID_VARIABLE_NAME) String serviceId,
        HttpServletRequest request) {

    logger.info("Received processes request (overview of available processes) for service id \"{}\"!",
            serviceId);

    parameterValueStore.addParameterValuePair(URL_Constants_TAMIS.SERVICE_ID_VARIABLE_NAME, serviceId);

    Processes_Tamis processesOverview = processesRequestForwarder.forwardRequestToWpsProxy(request, null,
            parameterValueStore);

    return ResponseEntity.ok(processesOverview);
}

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

@CrossOrigin
@RequestMapping(value = "/refresh", method = RequestMethod.GET)
public ResponseEntity<?> authenticationRequest(HttpServletRequest request) {
    String token = request.getHeader(this.tokenHeader);
    String username = this.tokenUtils.getUsernameFromToken(token);
    SecurityUser user = (SecurityUser) this.userDetailsService.loadUserByUsername(username);
    if (this.tokenUtils.canTokenBeRefreshed(token, user.getLastPasswordReset())) {
        String refreshedToken = this.tokenUtils.refreshToken(token);
        return ResponseEntity.ok(new AuthenticationResponse(refreshedToken));
    } else {//from w  ww .  j  a v a 2  s.  c o m
        return ResponseEntity.badRequest().body(null);
    }
}

From source file:com.github.gregwhitaker.asyncshowdown.HelloController.java

/**
 * Blocks for a random random number of milliseconds, within the specified minimum and maximum, before returning a 200 HTTP
 * response with the body containing the string "Hello World!"
 *
 * @param minSleep minimum sleep time in milliseconds
 * @param maxSleep maximum sleep time in milliseconds
 * @return A 200 HTTP response with the body containing the string "Hello World!"
 * @throws Exception// ww w. j av  a2 s  .c  om
 */
@RequestMapping(value = "/helloblocking", method = RequestMethod.GET)
public ResponseEntity<String> helloBlocking(
        @RequestParam(name = "minSleepMs", defaultValue = "500") long minSleep,
        @RequestParam(name = "maxSleepMs", defaultValue = "500") long maxSleep) throws Exception {
    return ResponseEntity.ok(new HelloGenerator(minSleep, maxSleep).call());
}

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

@RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity getUsers(Authentication _authentication) {

    List<User> userList = users.all();

    return ResponseEntity.ok(userList);
}

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

@RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity getVhosts(Authentication _authentication) {

    List<Vhost> vhostList = vhosts.all();

    return ResponseEntity.ok(vhostList);
}

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

@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/token/{tokenId}", method = RequestMethod.GET)
@ApiOperation(value = "Get a token", notes = "", response = Token.class, nickname = "getToken")
public ResponseEntity<?> get(@AuthenticationPrincipal User user, @PathVariable Long tokenId) {

    Token token = tokenService.read(tokenId);

    // TODO add ACL checks
    if (user.getId().longValue() != token.getUser().getId().longValue()) {
        return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
                .body(new JsonErrorResponse(HttpStatus.UNAUTHORIZED.value(), "Not authorized"));
    }//from   w w w  .  j a  v  a2s  .co  m

    return ResponseEntity.ok(token);
}

From source file:fr.lepellerin.ecole.web.controller.cantine.DetaillerReservationRepasController.java

@RequestMapping(value = "/reserver")
@ResponseBody//w  w  w. j  a  va2s  .  c  om
public ResponseEntity<String> reserver(@RequestParam final String date, @RequestParam final int individuId)
        throws TechnicalException {
    final CurrentUser user = (CurrentUser) SecurityContextHolder.getContext().getAuthentication()
            .getPrincipal();
    final LocalDate localDate = LocalDate.parse(date,
            DateTimeFormatter.ofPattern(GeDateUtils.DATE_FORMAT_YYYYMMDD, Locale.ROOT));
    String result;
    try {
        result = this.cantineService.reserver(localDate, individuId, user.getUser().getFamille(), null);
        return ResponseEntity.ok(result);
    } catch (FunctionalException e) {
        LOGGER.error("Une erreur fonctionnelle s'est produite : " + e.getMessage(), e);
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
    }
}

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

@ApiOperation(value = "Retrieve all mirrors registered", response = MirrorReference.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, value = "", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAll() {
    return ResponseEntity.ok(Lists.newArrayList(this.mirrorReferenceRepo.findAll()));
}