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 = "/student/{id}", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getFileStudent(@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;/*ww  w. ja  v  a 2s  .  c om*/
}

From source file:com.sdl.odata.client.caller.MockController.java

@RequestMapping(value = RESPONSE)
ResponseEntity<?> respondWithXML() {
    try (InputStream stream = getClass().getResourceAsStream("/" + RESPONSE)) {
        return ResponseEntity.ok().body(copyToString(stream, UTF_8));
    } catch (IOException e) {
        return ResponseEntity.notFound().build();
    }//from   ww  w .j ava 2 s  .  c  o  m
}

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

@RequestMapping(value = "/message/inbound", method = RequestMethod.POST)
public ResponseEntity inboundMessage(@RequestParam("processId") String processId,
        @RequestBody String messageData) {
    messagingTemplate.convertAndSend("/topic/messages",
            MessageEvent.createEvent(processId, MessageEvent.INBOUND, messageData));
    return ResponseEntity.ok().build();
}

From source file:com.consol.citrus.demo.voting.web.VotingServiceController.java

@RequestMapping(method = RequestMethod.DELETE)
@ResponseBody
public ResponseEntity clear() {
    votingService.clear();
    return ResponseEntity.ok().build();
}

From source file:com.saasovation.identityaccess.resource.TenantResource.java

@GetMapping(value = "{tenantId}", produces = OvationsMediaType.ID_OVATION_TYPE)
public ResponseEntity<String> getTenant(@PathVariable("tenantId") String aTenantId) {

    Tenant tenant = this.identityApplicationService().tenant(aTenantId);

    if (tenant == null) {
        return ResponseEntity.notFound().build();
    }/*from w  ww .  jav a 2  s .c  o  m*/

    String tenantRepresentation = ObjectSerializer.instance().serialize(tenant);

    return ResponseEntity.ok().cacheControl(this.cacheControlFor(5)).body(tenantRepresentation);
}

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

@RequestMapping(value = "/{id}", method = RequestMethod.PUT, headers = "content-type=application/x-www-form-urlencoded")
@ResponseBody//w ww .j a v  a  2  s .  c  om
public ResponseEntity setEntryStatus(@PathVariable(value = "id") String id,
        @RequestParam(value = "done") boolean done) {
    todoListService.setStatus(UUID.fromString(id), done);
    return ResponseEntity.ok().build();
}

From source file:controllers.frontend.PostController.java

@GetMapping("/image/{postId}")
@ResponseBody/* w ww. ja  va 2 s  .  c o  m*/
public ResponseEntity<byte[]> downloadPostImage(@PathVariable Long postId) throws SQLException {
    FileImage postImage = postService.getImageByPostId(postId);
    logger.info("Post Image Information: " + postImage.toString());
    return ResponseEntity.ok().contentLength(postImage.getSize())
            .contentType(MediaType.parseMediaType(postImage.getContentType())).body(postImage.getContent());
}

From source file:ch.heigvd.gamification.api.EventsEndpoint.java

@Override
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity reportEvent(
        @ApiParam(value = "token that identifies the app sending the request", required = true) @RequestHeader(value = "X-Gamification-Token", required = true) String xGamificationToken,
        @ApiParam(value = "The event that occured in the realm of the gamified application", required = true) @RequestBody EventDTO event) {

    try {/*w  ww .j  av a2s.c om*/
        eventProcessor.processEvent(xGamificationToken, event);
    } catch (DataIntegrityViolationException e) {

        eventProcessor.processEvent(xGamificationToken, event);
    }

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

From source file:com.saasovation.identityaccess.resource.GroupResource.java

private ResponseEntity<String> groupResponse(

        Group aGroup) {//from   w ww  .  j a v  a 2s  . c o  m

    String representation = ObjectSerializer.instance().serialize(aGroup);

    return ResponseEntity.ok().cacheControl(this.cacheControlFor(30)).body(representation);
}

From source file:com.mycompany.testdowload.controller.DocumentFileController.java

@RequestMapping(value = "/getfile/{id}", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getFile(@PathVariable("id") UploadFile 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;//  ww w  .j  a v  a2  s.co  m
}