Example usage for org.springframework.http HttpStatus NOT_FOUND

List of usage examples for org.springframework.http HttpStatus NOT_FOUND

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus NOT_FOUND.

Prototype

HttpStatus NOT_FOUND

To view the source code for org.springframework.http HttpStatus NOT_FOUND.

Click Source Link

Document

404 Not Found .

Usage

From source file:com.example.notes.RestNotesControllerAdvice.java

@ExceptionHandler(ResourceDoesNotExistException.class)
public void handleResourceDoesNotExistException(ResourceDoesNotExistException ex, HttpServletRequest request,
        HttpServletResponse response) throws IOException {
    response.sendError(HttpStatus.NOT_FOUND.value(),
            "The resource '" + request.getRequestURI() + "' does not exist");
}

From source file:com.jiwhiz.rest.RestErrorHandler.java

/**
 * Return 404 Not Found if resource cannot be found.
 * //from   w  ww.j  a  v  a  2 s  .c o  m
 * @param ex
 */
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public void handleResourceNotFoundException(ResourceNotFoundException ex) {
    LOGGER.debug("handling 404 error on a resource");
}

From source file:de.codecentric.boot.admin.actuate.LogfileMvcEndpointTest.java

@Test
public void logfile_noFile() throws IOException {
    controller.setLogfile("does_not_exist.log");

    assertEquals(HttpStatus.NOT_FOUND, controller.available().getStatusCode());

    MockHttpServletResponse response = new MockHttpServletResponse();
    controller.invoke(response);/*from w w  w.  j  a v a  2  s.co m*/
    assertEquals(HttpStatus.NOT_FOUND.value(), response.getStatus());
}

From source file:github.priyatam.springrest.resource.DriverResource.java

@RequestMapping(method = RequestMethod.GET, value = "/driver/{licenseNo}")
@ResponseBody/*  ww w.  j  a  v  a  2s. c om*/
public ResponseEntity<Driver> getDriver(@PathVariable String licenseNo) {
    logger.debug(String.format("Retrieving Driver %s :", licenseNo));

    Driver driver = persistenceHelper.loadDriverByLicenseNum(licenseNo);
    if (driver == null) {
        logger.warn("No Driver found");
        return new ResponseEntity<Driver>(null, new HttpHeaders(), HttpStatus.NOT_FOUND);
    }

    // Convert to Restful Resource, update ETag and HATEOAS references
    responseBuilder.toDriver(Lists.newArrayList(driver));

    return new ResponseEntity<Driver>(driver, HttpStatus.OK);
}

From source file:com.opensearchserver.hadse.index.IndexController.java

@RequestMapping(method = RequestMethod.GET, value = "/{index_name}")
@ResponseBody//  w  w  w.  j ava 2s .  co m
public HttpEntity<?> indexExists(@PathVariable String index_name) {
    if (!IndexCatalog.exists(index_name))
        return new ResponseEntity<String>("Index not found: " + index_name, HttpStatus.NOT_FOUND);
    return new ResponseEntity<String>("Index found", HttpStatus.FOUND);

}

From source file:jp.classmethod.aws.brian.web.ErrorController.java

@ResponseBody
@ResponseStatus(HttpStatus.NOT_FOUND)
@RequestMapping("/404")
public BrianResponse<String> notFound(HttpServletRequest req) {
    logger.info("notFound invoked: {}", req);
    return new BrianResponse<>(false, "404 - Not Found", null);
}

From source file:edu.sjsu.cmpe275.project.controller.RoomController.java

/** Get all rooms
 * @return   List<Room></Room>
 *///from   w w w. j a  va 2  s . co  m

@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseEntity<?> createRoom() {

    List<Room> rooms = roomDao.getAllRoom();
    if (rooms == null) {
        return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
    } else {
        return new ResponseEntity<Object>(rooms, HttpStatus.OK);
    }
}

From source file:org.nubomedia.marketplace.api.exceptions.GlobalExceptionHandler.java

@ExceptionHandler({ NotFoundException.class })
@ResponseStatus(value = HttpStatus.NOT_FOUND)
protected ResponseEntity<Object> handleNotFoundException(HttpServletRequest req, Exception e) {
    log.error("Exception with message " + e.getMessage() + " was thrown");
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    Map body = new HashMap<>();
    body.put("error", "Not Found");
    body.put("exception", e.getClass().toString());
    body.put("message", e.getMessage());
    body.put("path", req.getRequestURI());
    body.put("status", HttpStatus.NOT_FOUND.value());
    body.put("timestamp", new Date().getTime());
    ResponseEntity responseEntity = new ResponseEntity(body, headers, HttpStatus.NOT_FOUND);
    return responseEntity;
}

From source file:edu.eci.arsw.kalendan.controllers.TeamResourceController.java

@RequestMapping(path = "/equipos/{idT}", method = RequestMethod.GET)
public ResponseEntity<?> teamGetMembers(@PathVariable("idT") Integer teamid) {
    try {//from   w w  w  .ja v a 2 s .  c  o  m

        return new ResponseEntity<>(ts.getEquipo(teamid), HttpStatus.ACCEPTED);

    } catch (Exception ex) {
        Logger.getLogger(TeamResourceController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.expedia.seiso.web.controller.ExceptionHandlerAdvice.java

@ExceptionHandler(NotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody//w w  w.j  a  v a2s  .  c  o m
public ErrorObject handleNotFoundException(NotFoundException e, WebRequest request) {
    return new ErrorObject(C.EC_RESOURCE_NOT_FOUND, e.getMessage());
}