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.allogy.amazonaws.elasticbeanstalk.worker.simulator.application.WorkerApplication.java

public HttpStatus forward(MessageWrapper messageWrapper) {
    Message message = messageWrapper.getMessage();
    HttpEntity<String> messageEntity = createHttpEntity(messageWrapper, message);

    logger.info("Forwarding message: messageId={}", messageWrapper.getMessage().getMessageId());

    try {//from   w w  w. ja v  a2 s  . c o  m
        ResponseEntity<String> responseEntity = restTemplate.exchange(targetUrl, HttpMethod.POST, messageEntity,
                String.class);
        return responseEntity.getStatusCode();
    } catch (HttpStatusCodeException ex) {
        HttpStatus statusCode = ex.getStatusCode();
        logger.error("The HTTP Worker Application returned a non successful error code. statusCode={}",
                statusCode);
        return statusCode;
    } catch (RestClientException ex) {
        logger.error("Unable to connect to the HTTP Worker Application.");
        return HttpStatus.NOT_FOUND;
    }
}

From source file:net.oneandone.stool.overview.ProcessesController.java

@RequestMapping(value = "{id}/log", method = RequestMethod.GET)
@ResponseBody//from  w w  w .  ja  va2s.c om
public ResponseEntity log(@PathVariable(value = "id") String id,
        @RequestParam(defaultValue = "0") Integer index) throws IOException, InterruptedException {
    Node logfile;
    StringBuilder output;
    MultiValueMap<String, String> headers;
    output = new StringBuilder();
    List<String> strings;
    ListIterator<String> iterator;

    headers = new HttpHeaders();

    try {
        logfile = logFile(id);
    } catch (ResourceNotFoundException e) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    strings = logfile.readLines();
    iterator = strings.listIterator(index);
    while (iterator.hasNext()) {
        output.append(iterator.next()).append("<br />");
    }
    headers.set("X-index", "" + strings.size());
    return new ResponseEntity<>(output.toString(), headers, HttpStatus.OK);
}

From source file:pitayaa.nail.msg.core.account.controller.AccountLicenseController.java

@RequestMapping(value = "/accountsLicense/{ID}", method = RequestMethod.GET)
public @ResponseBody ResponseEntity<?> findOneAccLicense(@PathVariable("ID") UUID uid) throws Exception {

    Optional<AccountLicense> accountLicense = accLicenseService.findOne(uid);

    if (!accountLicense.isPresent()) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    } else {//w  ww .  j  a v a 2s.  c  o m
        return new ResponseEntity<>(accountLicense, HttpStatus.OK);
    }
}

From source file:ca.qhrtech.controllers.TableController.java

@RequestMapping("/table/game/{id}")
public ResponseEntity<List<BGLTable>> getTablesForGame(@PathVariable("id") long id) {
    if (gameService.findGameById(id) == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*  www . java2  s. c o  m*/
    return new ResponseEntity<>(tableService.getTablesForGame(id), HttpStatus.OK);
}

From source file:com.example.SampleWebFreeMarkerApplicationTests.java

@Test
public void testFreeMarkerErrorTemplate() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    HttpEntity<String> requestEntity = new HttpEntity<String>(headers);

    ResponseEntity<String> responseEntity = new TestRestTemplate().exchange(
            "http://localhost:" + this.port + "/" + contextPath + "/does-not-exist", HttpMethod.GET,
            requestEntity, String.class);

    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
    assertThat(responseEntity.getBody()).contains("Something went wrong: 404 Not Found");
}

From source file:ca.hec.tenjin.tool.controller.ImportController.java

@RequestMapping(value = "/import/{siteId}", method = RequestMethod.POST)
public @ResponseBody ResponseEntity<Syllabus> importSyllabus(@PathVariable("siteId") String siteId)
        throws DeniedAccessException, SyllabusLockedException {

    if (importProvider == null) {
        return new ResponseEntity<Syllabus>(HttpStatus.NOT_IMPLEMENTED);
    }//  w w  w .  j av a2 s.  c o  m

    Syllabus syllabus = syllabusService.importSyllabusFromSite(siteId);
    if (syllabus != null) {
        return new ResponseEntity<Syllabus>(syllabus, HttpStatus.OK);
    } else {
        return new ResponseEntity<Syllabus>(HttpStatus.NOT_FOUND);
    }

}

From source file:org.zalando.boot.etcd.EtcdClientTest.java

@Test(expected = EtcdException.class)
public void getWithResourceAccessException() throws EtcdException {
    server.expect(MockRestRequestMatchers.requestTo("http://localhost:2379/v2/keys/sample"))
            .andExpect(MockRestRequestMatchers.method(HttpMethod.GET))
            .andRespond(MockRestResponseCreators.withStatus(HttpStatus.NOT_FOUND)
                    .contentType(MediaType.APPLICATION_JSON)
                    .body(new ClassPathResource("EtcdClientTest_get.json")));

    try {// w  ww .j a v a  2 s  .  c o  m
        client.get("sample");
    } finally {
        server.verify();
    }
}

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

/**{@inheritDoc}*/
@Override/*from  w  ww. ja v a2  s  . c  o  m*/
@RequestMapping(value = "/imagenes/{rawBlobKey}", method = RequestMethod.GET)
public @ResponseBody void getImage(@PathVariable String rawBlobKey, HttpServletResponse response) {
    try {
        BlobKey blobKey = new BlobKey(rawBlobKey);
        blobstoreService.serve(blobKey, response);
    } catch (Exception e) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
    }
}

From source file:com.tamnd2.basicwebapp.rest.mvc.BlogEntryController.java

@RequestMapping(value = "/{blogEntryId}", method = RequestMethod.PUT)
public ResponseEntity<BlogEntryResource> updateBlogEntry(@PathVariable Long blogEntryId,
        @RequestBody BlogEntryResource sentBlogEntry) {
    BlogEntry updatedEntry = service.updateBlogEntry(blogEntryId, sentBlogEntry.toBlogEntry());
    if (updatedEntry != null) {
        BlogEntryResource res = new BlogEntryResourceAsm().toResource(updatedEntry);
        return new ResponseEntity<BlogEntryResource>(res, HttpStatus.OK);
    } else {/*from  ww  w  . ja  va  2s .c  o  m*/
        return new ResponseEntity<BlogEntryResource>(HttpStatus.NOT_FOUND);
    }
}

From source file:org.cloudfoundry.test.ServiceController.java

@RequestMapping(value = "/mysql/max-active", method = RequestMethod.GET)
public ResponseEntity<String> getMySQLDataSourceMaxActive() {
    if (serviceHolder.getMySqlDataSource() == null) {
        return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
    }//from ww  w  . j  a  v a 2 s  . c  o m
    return new ResponseEntity<String>("" + serviceHolder.getMySqlDataSource().getMaxActive(), HttpStatus.OK);
}