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:io.github.cdelmas.spike.springboot.car.CarsController.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<CarRepresentation> byId(@PathVariable("id") String carId) {
    Optional<Car> car = carRepository.byId(Integer.parseInt(carId));
    return car.map(c -> {
        CarRepresentation rep = toCarRepresentation(c);
        return new ResponseEntity<>(rep, HttpStatus.OK);
    }).orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}

From source file:de.hska.ld.oidc.controller.DocumentSSSInfoController.java

@Secured(Core.ROLE_USER)
@RequestMapping(method = RequestMethod.GET, value = "/document/{documentId}/episode")
@Transactional/*w  w w. j av a  2 s . co  m*/
public Callable getEpisodeId(@PathVariable Long documentId) {
    return () -> {
        Document document = documentService.findById(documentId);
        if (document == null) {
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }
        DocumentSSSInfo documentSSSInfo = documentSSSInfoService.getDocumentSSSInfo(document);
        if (documentSSSInfo == null) {
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }
        return new ResponseEntity<>(documentSSSInfo, HttpStatus.OK);
    };
}

From source file:org.cloudfoundry.runtime.CloudServicesScannerTest.java

/**
 * Verifies that service scan will create beans for bound services when we
 * do not have services of all types deployed
 *
 * @throws IOException//from  w  w  w .j  a  v  a2 s .  c o  m
 */
@SuppressWarnings("unchecked")
@Test
public void serviceScanMissingSomeServices() throws IOException {
    List<String> serviceNames = createServicesMinusMongo();
    createAndStartApp("cf-runtime-test-app", serviceNames);
    assertTrue("Test application is not available",
            testAppCreator.isAppAvailable(computeAppUrl(), 500l, 120000l));
    Map<String, Object> cloudProps = restTemplate.getForObject(computeAppUrl() + "/properties", Map.class);
    assertFalse(cloudProps.isEmpty());
    // Check for 404s on rest of dependencies
    restTemplate.getForObject(computeAppUrl() + "/mysql", String.class);
    restTemplate.getForObject(computeAppUrl() + "/redis/class", String.class);
    restTemplate.getForObject(computeAppUrl() + "/rabbit", String.class);
    restTemplate.getForObject(computeAppUrl() + "/postgres", String.class);
    try {
        restTemplate.getForObject(computeAppUrl() + "/mongo", String.class);
        fail("Mongo service bean should not be created");
    } catch (HttpClientErrorException e) {
        if (!(e.getStatusCode().equals(HttpStatus.NOT_FOUND))) {
            fail("Expected a 404 when looking for mongo service bean.  Got: " + e);
        }
    }
}

From source file:ch.heigvd.gamification.api.ApplicationsEndpoint.java

@Override
@RequestMapping(value = "/{applicationName}", method = RequestMethod.GET)
public ResponseEntity<ApplicationDTO> applicationsApplicationNameGet(
        @ApiParam(value = "applicationName", required = true) @PathVariable("applicationName") String applicationUsername) {

    Application app = apprepository.findByName(applicationUsername);
    UriComponents uriComponents = MvcUriComponentsBuilder.fromMethodName(BadgesEndpoint.class, "badgesGet", 1)
            .build();/*  w w w  . j a  v  a 2s .co  m*/

    if (app == null) {

        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    ApplicationDTO dto = toDTO(app, uriComponents);

    if (dto == null) {
        return new ResponseEntity<>(dto, HttpStatus.NOT_FOUND);
    } else {
        return new ResponseEntity<>(dto, HttpStatus.OK);
    }
}

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

@RequestMapping(value = "/day", method = RequestMethod.GET)
public ResponseEntity<?> getDay() {
    List<Factura> list = facadeService.getFacturaDAO().getDiaryReserva();
    if (!list.isEmpty()) {
        return new ResponseEntity<>(list, HttpStatus.OK);
    } else {// www. ja v  a2 s. c  o m
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.graphaware.module.uuid.api.UuidApi.java

@ExceptionHandler(NotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public void handleNotFound() {

}

From source file:com.auditbucket.company.endpoint.CompanyEP.java

@RequestMapping(value = "/{companyName}", method = RequestMethod.GET)
@ResponseBody//ww w  . ja v a  2  s .  c o  m
public ResponseEntity<Company> getCompany(@PathVariable("companyName") String companyName, String apiKey,
        @RequestHeader(value = "Api-Key", required = false) String apiHeaderKey) throws DatagioException {
    // curl -u mike:123 -X GET http://localhost:8080/ab/company/Monowai

    getCompany(apiHeaderKey, apiKey);
    Company company = companyService.findByName(companyName);
    if (company == null)
        return new ResponseEntity<>(company, HttpStatus.NOT_FOUND);
    //ToDo figure out companyName strategy
    SystemUser sysUser = securityHelper.getSysUser(true);
    if (!sysUser.getCompany().getId().equals(company.getId())) {
        // Not Authorised
        return new ResponseEntity<>(company, HttpStatus.FORBIDDEN);
    } else {
        return new ResponseEntity<>(company, HttpStatus.OK);
    }
}

From source file:ch.wisv.areafiftylan.exception.GlobalControllerExceptionHandler.java

@ExceptionHandler(TicketNotFoundException.class)
public ResponseEntity<?> handleTicketNotFoundException(TicketNotFoundException ex) {
    return createResponseEntity(HttpStatus.NOT_FOUND, ex.getMessage());
}

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

/**
 * Get a single application./*from  w  w  w. ja va 2  s. c om*/
 * 
 * @param id The application identifier.
 * @return The application.
 */
@RequestMapping(value = "/api/instance/{id}", method = RequestMethod.GET)
public ResponseEntity<Instance> instance(@PathVariable String id) {
    LOGGER.debug("Deliver application with ID '{}'", id);
    Instance instance = repository.findInstance(id);
    if (instance != null) {
        return new ResponseEntity<Instance>(instance, HttpStatus.OK);
    } else {
        return new ResponseEntity<Instance>(HttpStatus.NOT_FOUND);
    }
}

From source file:org.zalando.github.spring.MembersTemplate.java

@Override
public boolean isMemberOfOrganization(String organization, String username) {
    Map<String, Object> uriVariables = new HashMap<>();
    uriVariables.put("organization", organization);
    uriVariables.put("username", username);

    HttpStatus status = HttpStatus.NOT_FOUND;
    try {/*from   www .ja  v a  2s . com*/

        ResponseEntity<Void> responseEntity = getRestOperations()
                .getForEntity(buildUri("/orgs/{organization}/members/{username}", uriVariables), Void.class);
        status = responseEntity.getStatusCode();
    } catch (HttpClientErrorException e) {
        // skip
    }
    return HttpStatus.NO_CONTENT.equals(status) ? true : false;
}