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:$.TaskRestController.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8)
    public Task get(@PathVariable("id") Long id) {
        Task task = taskService.getTask(id);
        if (task == null) {
            String message = "?(id:" + id + ")";
            logger.warn(message);//from w  w w  .  j  a  v a2 s . co  m
            throw new RestException(HttpStatus.NOT_FOUND, message);
        }
        return task;
    }

From source file:com.srinathavan.mwbng.rest.mvc.BlogController.java

/**
 * Method to blog entry data by its id/*from w  w  w.j av  a 2s .c o  m*/
 * 
 * @param blogId
 * @return
 */
@RequestMapping(value = "/{blogId}", method = RequestMethod.GET)
public @ResponseBody ResponseEntity<Object> getBlog(@PathVariable Long blogId) {
    Blog blog = blogService.findBlog(blogId);
    if (null != blog) {
        return new ResponseEntity<Object>(blog, HttpStatus.OK);
    } else {
        return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
    }
}

From source file:sagan.projects.support.BadgeControllerTest.java

@Test
public void badgeNotFound() throws Exception {

    ResponseEntity<byte[]> response = controller.releaseBadge("spring-data-redis");
    assertThat(response.getStatusCode(), is(equalTo(HttpStatus.NOT_FOUND)));
}

From source file:bg.vitkinov.edu.services.JokeCategoryService.java

@RequestMapping(value = "/search/{name}", method = RequestMethod.GET)
public ResponseEntity<?> getCategoryByName(@PathVariable String name) {
    Optional<Category> category = repository.findByName(name);
    return category.isPresent() ? new ResponseEntity<>(category.get(), HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

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

/** Search room availability
 * @param roomNum         Room No//from w  w  w . j a v  a 2s  .  co m
 * @param roomType         Room Type
 * @param smoking         smoking, non-smoking
 * @param checkinDate         check in date
 * @param checkoutDate         check out date
 * @return         void
 */

@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseEntity<?> createRoom(@RequestParam(value = "checkin_date", required = true) Date checkinDate,
        @RequestParam(value = "checkout_date", required = true) Date checkoutDate,
        @RequestParam(value = "room_num", required = true) Integer roomNum,
        @RequestParam(value = "room_type", required = false) Integer roomType,
        @RequestParam(value = "smoking", required = true) Boolean smoking) {

    List<Room> rooms = searchRoom.query(checkinDate, checkoutDate, roomNum, roomType, smoking);
    if (rooms == null) {
        return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
    } else {
        return new ResponseEntity<Object>(rooms, HttpStatus.OK);
    }

}

From source file:com.aplikasi.penjualan.controller.DataBarangController.java

@RequestMapping(value = "/barang/{kode}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)//from w  w w  .j a  va 2s.c  om
public ResponseEntity<DataBarang> cariDataBarang(@PathVariable("kode") String kode) {
    DataBarang hasil = kd.findOne(kode);
    //menambahkan error 404 jika data yang dicari tidak ada
    if (hasil == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity<>(hasil, HttpStatus.OK);
}

From source file:com.mycompany.bootcamelrestdsl.Application.java

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
    return new EmbeddedServletContainerCustomizer() {
        @Override//from w  w w. ja va2 s  . c o m
        public void customize(ConfigurableEmbeddedServletContainer container) {
            ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");

            container.addErrorPages(error401Page, error404Page, error500Page);
        }
    };
}

From source file:net.orpiske.tcs.service.rest.controller.TagCloudQueriesController.java

@RequestMapping(value = "/domain", method = RequestMethod.POST)
@ResponseBody/*from  ww w .  jav a2 s .co  m*/
public ResponseEntity<TagCloud> requestCspTagCloud(@RequestBody final Domain domain) {

    if (logger.isDebugEnabled()) {
        logger.debug("Requesting the CSP tag cloud for " + domain.getDomain());
    }

    TagCloudEvent tagCloudEvent = tagCloudService.requestTagCloud(new RequestTagCloudEvent(domain));

    if (!tagCloudEvent.isEntityFound()) {
        return new ResponseEntity<TagCloud>(HttpStatus.NOT_FOUND);
    }

    TagCloud tagCloud = tagCloudEvent.getCspTagCloud();

    return new ResponseEntity<TagCloud>(tagCloud, HttpStatus.OK);
}

From source file:org.springsource.sinspctr.rest.SInspctrController.java

@ResponseBody
@RequestMapping(value = "/**/*.xml", method = RequestMethod.GET)
public ResponseEntity<String> findConfig(HttpServletRequest request) {
    ResponseEntity<String> response;
    try {/*  w  ww  . j a va 2  s .c  o  m*/
        String servletPath = request.getServletPath();
        if (servletPath.startsWith("/sinspctr/configs")) {
            servletPath = servletPath.substring("/sinspctr/configs".length(), servletPath.length());
        }
        File siConfigFile = ResourceLocator.getClasspathRelativeFile(servletPath);
        HttpHeaders headers = new HttpHeaders();
        headers.add("content-type", "application/xml");
        response = new ResponseEntity<String>(FileCopyUtils.copyToString(new FileReader(siConfigFile)), headers,
                HttpStatus.OK);
        return response;
    } catch (Exception e) {
        return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
    }
}