Package org.w3c.tools.resources

Examples of org.w3c.tools.resources.LookupResult


      ls = new LookupState(request);
  } catch (org.w3c.tools.resources.ProtocolException ex) {
      ex.printStackTrace();
      throw new HTTPException(ex);
  }
  LookupResult  lr = new LookupResult(null);
  ResourceReference rr = null; // cr
  ls.markInternal();
  if ( ! ls.hasMoreComponents() )
      return admin.getRootReference();
  // Lookup the target resource:
View Full Code Here


      (httpd) ssiframe.getFileResource().getServer();
        ResourceReference rr_root = server.getRootReference();
        try {
      FramedResource root = (FramedResource) rr_root.lock();
      LookupState ls = new LookupState(code);
      LookupResult lr = new LookupResult(rr_root);
      ResourceReference wrap = null;
      if (root.lookup(ls,lr))
          wrap = lr.getTarget();
      if (wrap != null) {
          try {
        if (wrap.lock() instanceof ServletWrapper) {
            wrappers.put(code,wrap);
            r_wrapper = wrap;
View Full Code Here

      root = (FramedResource) rr_root.lock();
      // Do the lookup:
      ResourceReference r_target = null;
      try {
    LookupState  ls = new LookupState(urlpath);
    LookupResult lr = new LookupResult(rr_root);
    root.lookup(ls, lr);
    r_target = lr.getTarget();
      } catch (Exception ex) {
    r_target = null;
      }
      if (r_target == null)
    return null;
View Full Code Here

    {
  ResourceReference local_root = getLocalRoot(rr_root, rr);
  try {
      FramedResource root = (FramedResource)local_root.lock();
      LookupState    ls   = new LookupState(path);
      LookupResult   lr   = new LookupResult(local_root);
      if (root.lookup(ls,lr)) {
    ResourceReference  target = lr.getTarget();
    if (target != null) {
        try {
      FramedResource res = (FramedResource)target.lock();
      if (res instanceof FileResource) {
          File file = ((FileResource)res).getFile();
View Full Code Here

  // Do the lookup:
  ResourceReference r_target = null;
  try {
      LookupState  ls = new LookupState(uripath);
      LookupResult lr = new LookupResult(rr_root);
      root.lookup(ls, lr);
      r_target = lr.getTarget();
  } catch (Exception ex) {
      r_target = null;
  }
  //then return its context
  if (r_target != null) {
View Full Code Here

      checkpoint();
      return;
  }
  try {
      LookupState   ls  = new LookupState(checkurl);
      LookupResult  lr  = new LookupResult(root.getResourceReference());
      if (root.lookup(ls,lr)) {
    ResourceReference  target = lr.getTarget();
    if (target != null) {
        try {
      Resource res = target.lock();
      if (res instanceof CheckpointResource) {
          ((CheckpointResource) res).activate();
View Full Code Here

  }
  if (request.getMethod().equals("TRACE")) {
      // check if the resource can be proxied
      boolean doit = true;
      LookupState   ls = new LookupState(request);
      LookupResult  lr = new LookupResult(root.getResourceReference());
      try {
    if ( root.lookup(ls, lr) ) {
        ResourceReference  target = lr.getTarget();
        if (target != null) {
      try {
          // this is plain ugly and won't work for proxy
          // not based on this resource
          // do we need another way to to this?
          FramedResource fr = (FramedResource) target.lock();
          Class cff = Class.forName(
                  "org.w3c.jigsaw.proxy.ForwardFrame");
          doit = (fr.getFrameReference(cff) == null);
      } catch (Exception ex) {
          // fail miserably to the fallback
      } finally {
          target.unlock();
      }
        }
    }
      } catch (Exception ex) {};
      if (doit) {
    Reply reply = request.makeReply(HTTP.OK);
    reply.setNoCache(); // don't cache this
    reply.setMaxAge(-1);
    // Dump the request as the body
    // Removed unused headers:
    // FIXME should be something else for chuncked stream
    ByteArrayOutputStream ba = new ByteArrayOutputStream();
    try {
        reply.setContentType(new MimeType("message/http"));
        request.dump(ba);
        reply.setContentLength(ba.size());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    reply.setStream(new ByteArrayInputStream(ba.toByteArray()));
    return reply;
      }
  }
  // Create a lookup state, and a lookup result:

  ProtocolException error = null;
  LookupState   ls = null;
  LookupResult  lr = null;
  // Run the lookup algorithm of root resource:
  // catch exception to get error (FIXME)
  try {
      lr = new LookupResult(root.getResourceReference());
      ls = new LookupState(request);

      if ( root.lookup(ls, lr) ) {
    if (lr.hasReply())
        return lr.getReply();
      }
  } catch (ProtocolException ex) {
      error = ex;
  } catch (Exception ex) {
      /*
       * We have a problem here, the error can be a configuration
       * or resource/extension problem, and it should be a
       * 5xx error, or it is a client side error and it should be
       * a 4xx error, ex, try with "Authorization:" and it fails.
       * For now we will reply with a 400, but with a FIXME
       */
      Reply err = request.makeReply(HTTP.BAD_REQUEST);
      err.setContent("<html><head><title>Bad Request</title></head>\n"
         + "<body><p>The server was not able to "
         + "understand this request</p></body></html>");
      error = new ProtocolException(err);
  }
  // Let the target resource perform the method
  ResourceReference  target = lr.getTarget();
  Reply              reply  = null;

  ResourceFilter filters[]  = lr.getFilters();
  int            infilter   = 0;

  if (error == null) {
      //call the ingoing filters:
      try {
View Full Code Here

  ResourceReference rr = server.getEditRoot();
  try {
      FramedResource root = (FramedResource) rr.lock();
      try {
    LookupState  ls = new LookupState(SERVLET_BASE_P);
    LookupResult lr =
        new LookupResult(root.getResourceReference());
    root.lookup(ls, lr);
    return lr.getTarget();
      } catch (ProtocolException ex) {
    ex.printStackTrace();
    return null;
      }
  } catch (InvalidResourceException ex) {
View Full Code Here

  try {
      FramedResource root = (FramedResource) rr.lock();
      try {
    DirectoryResource parent = (DirectoryResource) sdir.lock();
    LookupState  ls = new LookupState(uri);
    LookupResult lr =
        new LookupResult(root.getResourceReference());
    root.lookup(ls, lr);
    ResourceReference target = lr.getTarget();
    if (target != null) {
        try {
      ServletWrapper wrapper =
          (ServletWrapper) target.lock();
      initialize(name, wrapper, parent);
View Full Code Here

      return null;
  // Do the lookup:
  ResourceReference r_target = null;
  try {
      LookupState  ls = new LookupState(u);
      LookupResult lr = new LookupResult(rr_root);
      root.lookup(ls, lr);
      r_target = lr.getTarget();
  } catch (Exception ex) {
      r_target = null;
  }
  if (r_target != null) {
    try {
View Full Code Here

TOP

Related Classes of org.w3c.tools.resources.LookupResult

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.