Example usage for org.springframework.http ResponseEntity notFound

List of usage examples for org.springframework.http ResponseEntity notFound

Introduction

In this page you can find the example usage for org.springframework.http ResponseEntity notFound.

Prototype

public static HeadersBuilder<?> notFound() 

Source Link

Document

Create a builder with a HttpStatus#NOT_FOUND NOT_FOUND status.

Usage

From source file:br.com.stefanini.database.service.UserService.java

@RequestMapping("/user/find")
public ResponseEntity<User> getByLoginAndPassword(@RequestParam(name = "login", required = true) String login,
        @RequestParam(name = "password", required = true) String password) {

    User found = dao.findOneByLoginAndPassword(login, password);
    if (found == null)
        return ResponseEntity.notFound().build();

    return ResponseEntity.ok(found);
}

From source file:com.example.api.MessageApi.java

@GetMapping("{id}")
ResponseEntity<Message> getMessage(@PathVariable("id") long messageId) {
    final Optional<Message> messageById = databaseService.getMessageById(messageId);
    return messageById.map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build());
}

From source file:com.example.web.CustomerRestController.java

@RequestMapping(value = "/{id}", method = GET)
public ResponseEntity<?> get(@PathVariable Long id) {
    Customer customer = customerRepository.findOne(id);
    if (customer != null) {
        return ResponseEntity.ok(customer);
    }//ww w.j ava 2  s . c o  m
    return ResponseEntity.notFound().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 w w.  j a v a2s. c o  m*/

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

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

From source file:com.example.web.NewRestController.java

@RequestMapping(value = "/{id}", method = GET)
public ResponseEntity<?> get(@PathVariable Long id) {
    Student student = studentRepository.findOne(id);
    if (student != null) {
        return ResponseEntity.ok(student);
    }/*from   w w w . j a v  a2 s.  c  o  m*/
    return ResponseEntity.notFound().build();
}

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

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

    Group group = this.identityApplicationService().group(aTenantId, aGroupName);

    if (group == null) {
        return ResponseEntity.notFound().build();
    }/* w w w  . j  av  a2 s. co m*/

    return this.groupResponse(group);
}

From source file:com.example.resources.user.UserResource.java

@GetMapping(path = "me")
ResponseEntity<?> getMe(@AuthenticationPrincipal final OperatingUser operatingUser) {
    return userRepository.findById(operatingUser.getUserId()).map(User::new).map(ResponseEntity::ok)
            .orElseGet(() -> ResponseEntity.notFound().build());
}

From source file:cn.edu.zjnu.acm.judge.controller.ProblemController.java

@GetMapping(value = "{id}", produces = APPLICATION_JSON_VALUE)
public ResponseEntity<?> findOne(@PathVariable("id") long id, Locale locale) {
    Problem problem = problemMapper.findOne(id, locale.getLanguage());
    return problem != null ? ResponseEntity.ok(problem) : ResponseEntity.notFound().build();
}

From source file:com.github.vanroy.cloud.dashboard.controller.RegistryController.java

/**
 * Return instance history registration/cancellation
 * @return List of registered/cancelled instances
 *///from   ww  w.ja  v a 2 s  . co m
@RequestMapping(value = "/api/registry/history", method = RequestMethod.GET)
public ResponseEntity instancesHistory() {

    if (repository == null) {
        return ResponseEntity.notFound().build();
    }

    return ResponseEntity.ok(ImmutableMap.of("lastRegistered", repository.getRegisteredInstanceHistory(),
            "lastCancelled", repository.getCanceledInstanceHistory()));
}

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();
    }/*w w w  .j av  a  2s. c om*/
}