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:com.consol.citrus.samples.todolist.web.TodoController.java

@RequestMapping(method = RequestMethod.DELETE)
public ResponseEntity deleteEntryByTitle(@RequestParam(value = "title") String title) {
    todoListService.deleteEntry(title);/*from  www  .j  av a 2 s.  c o m*/
    return ResponseEntity.ok().build();
}

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

@RequestMapping(method = POST)
@ResponseBody//from www .jav a  2 s. c  om
public ResponseEntity hello(@RequestBody HelloCommand cmd) {
    String name = cmd.getName();
    if (name == null || name.length() == 0) {
        name = "World";
    }
    HelloResource resource = new HelloResource();
    resource.setMessage(String.format("Hello %s!", name));
    return ResponseEntity.ok().body(resource);
}

From source file:com.todo.backend.web.rest.AuthenticationApi.java

@RequestMapping(value = "/sign-up", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed/*from   w  w  w.  ja  v  a 2 s .co m*/
@Transactional
public ResponseEntity<SignUpResponse> signUp(@Valid @RequestBody SignUpRequest request) {
    log.debug("POST /sign-up {}", request);
    final User user = userService.signUp(request.getFirstName(), request.getLastName(), request.getUsername(),
            request.getPassword());
    return ResponseEntity.ok().body(convertToSignUpResponse(user));
}

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

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

From source file:de.document.controller.ProzedurController.java

@RequestMapping(value = "/versionnig/bearbeiten", method = { RequestMethod.POST })
public ResponseEntity versionnigBearbeiten(@RequestBody Prozedur request) {

    this.service.versionnigBearbeiten(request);
    return ResponseEntity.ok().build();
}

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

@RequestMapping(value = "/{id}/{option}", method = RequestMethod.PUT)
public ResponseEntity vote(@PathVariable("id") String votingId, @PathVariable("option") String option) {
    votingService.vote(new Vote(votingId, option));
    return ResponseEntity.ok().build();
}

From source file:edu.eci.cosw.postresYa.controller.ActivityController.java

/**
 * Busca la imagen a un postre asociado por medio de un cdigo dado
 * @param code/*  w  w w  .  j  av a2s  .c  om*/
 * @return ResponseEntity 
 */
@RequestMapping(value = "/{code}/picture", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getPostrePicture(@PathVariable String code) {

    try {
        return ResponseEntity.ok().contentType(MediaType.parseMediaType("image/jpg"))
                .body(new InputStreamResource(stub.getPostrePicture(code)));
    } catch (Exception e) {

        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.todo.backend.web.rest.UserApi.java

@RequestMapping(value = "/user/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed/*from  w  w w  .ja va  2 s. c  om*/
@Transactional(readOnly = true)
@PreAuthorize("hasAuthority('ADMIN')")
public ResponseEntity<ReadUserResponse> readUser(@PathVariable Long id) {
    log.debug("GET /user/{}", id);
    final Optional<User> result = Optional.ofNullable(userRepository.findOne(id));
    if (result.isPresent()) {
        return ResponseEntity.ok().body(convertToReadUserResponse(result.get()));
    }
    return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

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

@RequestMapping(value = "/parent/{id}", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getFileParent(@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  .ja  va 2  s .  c  o  m*/
}

From source file:com.todo.backend.web.rest.TodoApi.java

@RequestMapping(value = "/todo/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed//from   ww w  .  j  ava  2 s. c o  m
@Transactional(readOnly = true)
public ResponseEntity<ReadTodoResponse> readTodo(@PathVariable Long id) {
    log.debug("GET /todo/{}", id);
    final Optional<Todo> result = Optional.ofNullable(todoRepository.findOne(id));
    if (result.isPresent()) {
        return ResponseEntity.ok().body(convertToReadTodoResponse(result.get()));
    }
    return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}