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.sms.server.controller.JobController.java

@RequestMapping(value = "/{username}/{limit}", method = RequestMethod.GET)
public ResponseEntity<List<Job>> getJobsByUsername(@PathVariable("username") String username,
        @PathVariable("limit") Integer limit) {
    List<Job> jobs = jobDao.getJobsByUsername(username, limit);

    if (jobs == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*from   w  w w. j a  v a2s  . c o m*/

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

From source file:com.coffeebeans.services.controller.base.BaseController.java

@ResponseBody
@ExceptionHandler(NotFoundException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
ErrorResponse handleException(NotFoundException e) {
    return new ErrorResponse(HttpStatus.NOT_FOUND.toString(), e.getMessage(), "NOT FOUND (aka Huh?)");
}

From source file:net.thewaffleshop.nimbus.web.WebJarsController.java

@ResponseBody
@RequestMapping("/webjarslocator/{webjar}/**")
public ResponseEntity locateWebjarAsset(@PathVariable String webjar, HttpServletRequest request) {
    try {/* w w w  .j  a v  a 2  s . c o m*/
        String mvcPrefix = "/webjarslocator/" + webjar + "/";
        String mvcPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
        String fullPath = assetLocator.getFullPath(webjar, mvcPath.substring(mvcPrefix.length()));
        return new ResponseEntity(new ClassPathResource(fullPath), HttpStatus.OK);
    } catch (Exception e) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.ar.dev.tierra.api.controller.NotaCreditoController.java

@RequestMapping(value = "/search/id", method = RequestMethod.GET)
public ResponseEntity<?> getById(@RequestParam("idNota") int idNota) {
    NotaCredito notaCredito = facadeService.getNotaCreditoDAO().getById(idNota);
    if (notaCredito != null) {
        return new ResponseEntity<>(notaCredito, HttpStatus.OK);
    } else {/*  w w w.  j av  a 2 s.co  m*/
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:reconf.server.services.security.DeleteUserService.java

@RequestMapping(value = "/user/{user}", method = RequestMethod.DELETE)
@Transactional//from  www .j a va 2  s.c o  m
public ResponseEntity<Client> doIt(@PathVariable("user") String user, Authentication authentication) {

    if (ApplicationSecurity.isRoot(user)) {
        return new ResponseEntity<Client>(new Client(user, cannotDeleteRoot), HttpStatus.BAD_REQUEST);
    }

    if (!userDetailsManager.userExists(user)) {
        return new ResponseEntity<Client>(new Client(user, userNotFound), HttpStatus.NOT_FOUND);
    }

    userProducts.deleteByKeyUsername(user);
    userDetailsManager.deleteUser(user);
    return new ResponseEntity<Client>(HttpStatus.OK);
}

From source file:minium.developer.web.rest.js.SelectorGadgetResource.java

@RequestMapping(value = "/activate", method = { POST, GET })
public ResponseEntity<Void> activate() throws Exception {
    if (activated) {
        try {//from   w  ww. j a va 2  s  .  c  o m
            deactivate();
        } catch (Exception e) {
            log.warn("Could not deactivate selector gadget");
        }
    }

    SelectorGadgetWebElements elems = getSelectorGadgetWebElements();
    if (elems == null) {
        return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
    }
    elems.activateSelectorGadget();
    activated = true;

    return new ResponseEntity<Void>(HttpStatus.OK);
}

From source file:com.bodybuilding.argos.controller.TurbineStreamController.java

@RequestMapping("/turbine-stream/{cluster}")
public ResponseEntity<SseEmitter> streamHystrix(@PathVariable("cluster") String cluster) {
    Optional<HystrixClusterMonitor> clusterMonitor = clusterRegistry.getCluster(cluster);
    if (!clusterMonitor.isPresent()) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*from  w w w . j  a v  a2 s . c om*/

    final SseEmitter emitter = new SseEmitter(TimeUnit.DAYS.toMillis(45));

    SseEmitterUtil.bindObservable(emitter,
            clusterMonitor.get().observeJson().takeUntil(shutdown).subscribeOn(Schedulers.io()));

    return ResponseEntity.ok(emitter);
}

From source file:reconf.server.services.product.DeleteProductService.java

@RequestMapping(value = "/product/{prod}", method = RequestMethod.DELETE)
@Transactional/*from   w  w  w.j  a v  a2s. c om*/
public ResponseEntity<ProductResult> doIt(@PathVariable("prod") String product, Authentication auth) {

    if (!ApplicationSecurity.isRoot(auth)) {
        return new ResponseEntity<ProductResult>(HttpStatus.FORBIDDEN);
    }

    Product reqProduct = new Product(product, null);
    List<String> errors = DomainValidator.checkForErrors(reqProduct);

    if (!errors.isEmpty()) {
        return new ResponseEntity<ProductResult>(new ProductResult(reqProduct, errors), HttpStatus.BAD_REQUEST);
    }

    if (!products.exists(reqProduct.getName())) {
        return new ResponseEntity<ProductResult>(new ProductResult(reqProduct, Product.NOT_FOUND),
                HttpStatus.NOT_FOUND);
    }

    products.delete(reqProduct.getName());
    components.deleteByKeyProduct(reqProduct.getName());
    properties.deleteByKeyProduct(reqProduct.getName());
    userProducts.deleteByKeyProduct(reqProduct.getName());
    return new ResponseEntity<ProductResult>(HttpStatus.OK);
}

From source file:cn.aozhi.songify.rest.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  ww  w.  j a  va  2  s  .  co m
        throw new RestException(HttpStatus.NOT_FOUND, message);
    }
    return task;
}

From source file:com.ar.dev.tierra.api.controller.DetalleNotaCreditoController.java

@RequestMapping(value = "/barcode", method = RequestMethod.GET)
public ResponseEntity<?> getByProductoOnFactura(@RequestParam("barcode") String barcode) {
    List<DetalleFactura> list = facadeService.getDetalleNotaCreditoDAO().getByBarcodeOnFactura(barcode);
    if (!list.isEmpty()) {
        return new ResponseEntity<>(list, HttpStatus.OK);
    } else {//from   ww w  .j  a  v  a 2  s .c o m
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}