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.orange.ngsi.client.UpdateContextSubscriptionTest.java

@Test(expected = HttpClientErrorException.class)
public void subscribeContextRequestWith404() throws Exception {

    this.mockServer.expect(requestTo(baseUrl + "/ngsi10/updateContextSubscription"))
            .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.NOT_FOUND));

    ngsiClient.updateContextSubscription(baseUrl, null, createUpdateContextSubscriptionTemperature()).get();
}

From source file:edu.eci.arsw.pacm.controllers.PacmRESTController.java

@RequestMapping(path = "/{salanum}/protectores", method = RequestMethod.GET)
public ResponseEntity<?> getProtectores(@PathVariable(name = "salanum") String salanum) {

    try {// ww w  .j  a  v a2s  .c o  m
        return new ResponseEntity<>(services.getProtectores(Integer.parseInt(salanum)), HttpStatus.ACCEPTED);
    } catch (ServicesException ex) {
        Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>(ex.getLocalizedMessage(), HttpStatus.NOT_FOUND);
    } catch (NumberFormatException ex) {
        Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>("/{salanum}/ must be an integer value.", HttpStatus.BAD_REQUEST);
    }
}

From source file:ch.wisv.areafiftylan.extras.consumption.controller.ConsumptionController.java

@ExceptionHandler(value = ConsumptionNotFoundException.class)
public ResponseEntity<?> handleConsumptionNotSupported(ConsumptionNotFoundException e) {
    return createResponseEntity(HttpStatus.NOT_FOUND, e.getMessage());
}

From source file:org.springsource.restbucks.payment.web.PaymentController.java

/**
 * Shows the {@link Receipt} for the given order.
 *
 * @param order//from   www. j  av a  2s. c  o  m
 * @return
 */
@RequestMapping(path = PaymentLinks.RECEIPT, method = GET)
HttpEntity<?> showReceipt(@PathVariable("id") Order order) {

    if (order == null || !order.isPaid() || order.isTaken()) {
        return ResponseEntity.notFound().build();
    }

    return paymentService.getPaymentFor(order).//
            map(payment -> createReceiptResponse(payment.getReceipt())).//
            orElseGet(() -> new ResponseEntity<>(HttpStatus.NOT_FOUND));
}

From source file:com.phoenixnap.oss.sample.server.controllers.DrinkControllerImpl.java

@Override
public ResponseEntity createDrink(CreateDrinkRequest createDrinkRequest) {
    LOG.debug("Entered createDrink endpoint");
    try {//from w  ww.j av  a2  s.  c om
        DrinkTypeEnum drinkType = DrinkTypeEnum.valueOf(String.valueOf(createDrinkRequest.getType()));
        AbstractDrink drink = null;
        switch (drinkType) {
        case ALCOHOL:
            drink = new AlcoholicDrink(createDrinkRequest.getName());
            break;
        case SOFT_DRINK:
            drink = new SoftDrink(createDrinkRequest.getName());
            break;
        default:
            LOG.error("Incorrect drink type passed: [{}] ", createDrinkRequest.getType());
            return new ResponseEntity(HttpStatus.BAD_REQUEST);
        }
        this.drinksService.addDrink(drink);
        LOG.info("Returning from createDrink");
        return new ResponseEntity(HttpStatus.ACCEPTED);
    } catch (DrinkNotFoundException dex) {
        return new ResponseEntity(HttpStatus.NOT_FOUND);
    }

}

From source file:com.orange.ngsi.client.UnsubscribeContextRequestTest.java

@Test(expected = HttpClientErrorException.class)
public void unsubscribeContextRequestWith404() throws Exception {

    this.mockServer.expect(requestTo(baseUrl + "/ngsi10/unsubscribeContext")).andExpect(method(HttpMethod.POST))
            .andRespond(withStatus(HttpStatus.NOT_FOUND));

    ngsiClient.unsubscribeContext(baseUrl, null, subscriptionID).get();
}

From source file:ru.org.linux.topic.UncommitedTopicsController.java

@ExceptionHandler(SectionNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ModelAndView handleNotFoundException() {
    return new ModelAndView("errors/code404");
}

From source file:be.bittich.quote.controller.impl.DefaultExceptionHandler.java

@RequestMapping(produces = APPLICATION_JSON)
@ExceptionHandler(ObjectRetrievalFailureException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public @ResponseBody Map<String, Object> handleValidationException(ObjectRetrievalFailureException ex)
        throws IOException {
    Map<String, Object> map = newHashMap();
    map.put("error", "Entity Not Found");
    map.put("cause", ex.getMessage());
    return map;//from w ww. j a  v  a 2s .  com
}

From source file:org.kurento.repository.RepositoryController.java

@RequestMapping(method = RequestMethod.GET, value = "/{itemId}/metadata")
public Map<String, String> getRepositoryItemMetadata(@PathVariable("itemId") String itemId,
        HttpServletResponse response) {//w  ww.java  2  s  .  c om
    try {
        return repoService.getRepositoryItemMetadata(itemId);
    } catch (ItemNotFoundException e) {
        try {
            response.sendError(HttpStatus.NOT_FOUND.value(), e.getMessage());
        } catch (IOException ioe) {
            ioe.printStackTrace();
            throw new KurentoException(ioe);
        }
        return null;
    }
}

From source file:org.nekorp.workflow.backend.controller.imp.RegistroCostoControllerImp.java

@Override
@RequestMapping(method = RequestMethod.POST)
public void crearRegistro(@PathVariable final Long idServicio, @Valid @RequestBody final RegistroCosto dato,
        final HttpServletResponse response) {
    dato.setId(null);/*w  w w.j av  a 2 s.  c  om*/
    if (!idServicioValido(idServicio)) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return;
    }
    this.registroCostoDAO.guardar(idServicio, dato);
    response.setStatus(HttpStatus.CREATED.value());
    response.setHeader("Location", "/servicios/" + idServicio + "/costo/registros/" + dato.getId());
}