Package org.tamacat.httpd.exception

Examples of org.tamacat.httpd.exception.NotFoundException


  @Override
  protected HttpEntity getEntity(String html) {
    try {
      return new StringEntity(html);
    } catch (UnsupportedEncodingException e) {
      throw new NotFoundException(e);
    }
  }
View Full Code Here


        handler = hostResolver.lookup(request, context);
      }
          if (handler != null) {
            handler.handle(request, response, context);
          } else {
              throw new NotFoundException();
          }
    } catch (Exception e) {
      if (e instanceof org.tamacat.httpd.exception.HttpException) {
        handleException(request, response,
            (org.tamacat.httpd.exception.HttpException)e);
View Full Code Here

      FileSystem fs = FileSystem.get(URI.create(uri), conf);
      Path p = new Path(uri);
      ///// 404 NOT FOUND /////
      if (fs.exists(p) == false) {
        LOG.trace("File " + path + " not found");
        throw new NotFoundException();
      }
      ///// FOR DIRECTORY /////
      else if (fs.isFile(p) == false) {
        if (useDirectoryListings()) {
          String html = listingPage.getListingsPage(
View Full Code Here

      String html = listingPage.getListingsPage(
          request, response, file);
      ResponseUtils.setEntity(response, getEntity(html));
      response.setStatusCode(HttpStatus.SC_OK);
    } catch (Exception e) {
      throw new NotFoundException(e);
    }
  }
View Full Code Here

    //Do not set an entity when it already exists.
    if (response.getEntity() == null) {
      try {
        File file = new File(docsRoot + getDecodeUri(path));//r.toURI());
        if (file.exists() == false) {
          throw new NotFoundException();
        }
        ResponseUtils.setEntity(response, getFileEntity(file));
      } catch (Exception e) {
        throw new NotFoundException(e);
      }
    }
  }
View Full Code Here

          if (request instanceof HttpEntityEnclosingRequest) {
            targetRequest = new ReverseHttpEntityEnclosingRequest(request, context, reverseUrl);
          } else {
            URL url = reverseUrl.getReverseUrl(request.getRequestLine().getUri());
            if (url == null) {
              throw new NotFoundException("url is null.");
            }
            BasicRequestLine line = new BasicRequestLine(
                request.getRequestLine().getMethod(),
                url.toString(),
                request.getRequestLine().getProtocolVersion());
View Full Code Here

    }
    File file = new File(docsRoot, getDecodeUri(path));
    ///// 404 NOT FOUND /////
    if (!file.exists()) {
      LOG.trace("File " + file.getPath() + " not found");
      throw new NotFoundException();
    }
    ///// 403 FORBIDDEN /////
    else if (!file.canRead() || file.isDirectory()) {
      if (file.isDirectory() && useDirectoryListings()) {
        String html = listingPage.getListingsPage(
View Full Code Here

  public void testGetPrintErrorPage() {
    VelocityErrorPage template = new VelocityErrorPage(props);
    HttpRequest request = new BasicHttpRequest("GET", "http://localhost/test");
    HttpResponse response = new BasicHttpResponse(
        new BasicStatusLine(new ProtocolVersion("HTTP",1,1), 404, "Not Found"));
    HttpException exception = new NotFoundException();
    String page = template.getErrorPage(request, response, exception);
    assertNotNull(page);
  }
View Full Code Here

         StringWriter writer = new StringWriter();
         template.merge(context, writer);
         return writer.toString();
      } catch (ResourceNotFoundException e) {
        LOG.trace(e.getMessage());
        throw new NotFoundException(e);
      } catch (Exception e) {
        throw new ServiceUnavailableException(e);
      }
    }
View Full Code Here

TOP

Related Classes of org.tamacat.httpd.exception.NotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.