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 BodyBuilder ok() 

Source Link

Document

Create a builder with the status set to HttpStatus#OK OK .

Usage

From source file:th.co.geniustree.intenship.advisor.controller.IndexController.java

@RequestMapping(value = "/teacher/{id}", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getFileTeacher(@PathVariable("id") FileUpload uploadFile) {
    ResponseEntity<InputStreamResource> body = ResponseEntity.ok().contentLength(uploadFile.getContent().length)
            .contentType(MediaType.parseMediaType(uploadFile.getMimeType()))
            .header("Content-Disposition", "attachment; filename=\"" + uploadFile.getName() + "\"")
            .body(new InputStreamResource(new ByteArrayInputStream(uploadFile.getContent())));
    return body;//from w  w w  . j  a va 2s. c om
}

From source file:io.github.jhipster.web.util.ResponseUtil.java

/**
 * Wrap the optional into a {@link ResponseEntity} with an {@link HttpStatus#OK} status with the headers,
 * or if it's empty, it returns a {@link ResponseEntity} with {@link HttpStatus#NOT_FOUND}.
 *
 * @param <X>           type of the response
 * @param maybeResponse response to return if present
 * @param header        headers to be added to the response
 * @return response containing {@code maybeResponse} if present or {@link HttpStatus#NOT_FOUND}
 *//*w  ww .  j  ava  2 s.c  o  m*/
public static <X> ResponseEntity<X> wrapOrNotFound(Optional<X> maybeResponse, HttpHeaders header) {
    return maybeResponse.map(response -> ResponseEntity.ok().headers(header).body(response))
            .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}

From source file:com.consol.citrus.samples.todolist.web.HealthController.java

@RequestMapping(method = RequestMethod.GET)
public ResponseEntity getHealth() {
    return ResponseEntity.ok().build();
}

From source file:io.github.azige.bbs.web.controller.AvatarController.java

@RequestMapping("/avatar/{id}")
public ResponseEntity<byte[]> avatarResource(@PathVariable Long id) throws IOException {
    return ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(IOUtils
            .toByteArray(AvatarController.class.getResourceAsStream("/io/github/azige/bbs/res/haruna.png")));
}

From source file:com.consol.citrus.admin.web.ConnectorController.java

@RequestMapping(value = "/status")
public ResponseEntity status() {
    return ResponseEntity.ok().build();
}

From source file:com.consol.citrus.samples.todolist.web.ReportingController.java

@RequestMapping(value = "/mail", method = RequestMethod.GET)
public ResponseEntity sendMailReport() {
    reportingService.sendMailReport();

    return ResponseEntity.ok().build();
}

From source file:edu.javeriana.patronessoftware.rest.DispatcherController.java

@RequestMapping(value = "/eliminar", method = RequestMethod.POST)
public ResponseEntity<Void> eliminar(@RequestBody Invernadero invernadero) {
    return ResponseEntity.ok().build();
}

From source file:io.jmnarloch.spring.cloud.feign.app.resource.AuthenticationResource.java

@RequestMapping(value = "/oauth2", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> getAuthorization(@RequestHeader("Authorization") String authorization) {

    return ResponseEntity.ok().header("Authorization", authorization).body(authorization);
}

From source file:edu.javeriana.patronessoftware.rest.DispatcherController.java

@RequestMapping(value = "/actualizaFrecuencia", method = RequestMethod.POST)
public ResponseEntity<Void> actualizaFrecuencia(@RequestBody Frecuencia frecuencia) {
    return ResponseEntity.ok().build();
}

From source file:com.github.cucumberspringtest.samples.helloworld.web.HelloController.java

@RequestMapping(method = GET)
@ResponseBody/*from w  ww.  j av a2 s. c  o m*/
public ResponseEntity hello(@RequestParam(value = "name", required = false) String name) {
    if (name == null || name.length() == 0) {
        name = "World";
    }
    HelloResource resource = new HelloResource();
    resource.setMessage(String.format("Hello %s!", name));
    return ResponseEntity.ok().body(resource);
}