Examples of FramedResource


Examples of org.w3c.tools.resources.FramedResource

  String best = null;

  ResourceReference rr = getResource().getParent();
  if (rr != null) {
      try {
    FramedResource p = (FramedResource)rr.lock();
    // if the father is a container (it should always be)
    if (p instanceof ContainerResource) {
        ContainerResource cr = (ContainerResource) p;
        Enumeration res_enum;
        res_enum = cr.enumerateResourceIdentifiers(false);
        String childname;
        ResourceReference childrr;
        Class http_class = null;
        ResourceReference framrr;
        // get all the children, and find the container with
        // the most recent last-modified.
        while (res_enum.hasMoreElements()) {
      childname = (String) res_enum.nextElement();
      childrr = cr.lookup(childname);
      try {
          FramedResource cp = (FramedResource)childrr.lock();
          if (cp instanceof ContainerResource) {
        long lm = cp.getLastModified();
        if ((lmbest == 0) || (lm > lmbest)) {
            lmbest = lm;
            best = childname;
        }
          }
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

          ResourceReference rr_root,
          ResourceReference rr)
    {
  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();
          return file.getAbsolutePath();
      } else if (res instanceof DirectoryResource) {
          DirectoryResource dir = (DirectoryResource) res;
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

    String index = indexes[i];
    if ( index != null && index.length() > 0) {
        ResourceReference rr = dir.lookup(index);
        if (rr != null) {
      try {
          FramedResource ri = (FramedResource) rr.lock();
          if (ri instanceof FileResource) {
        FileResource fr = (FileResource) ri;
        File file = fr.getFile();
        return file.getAbsolutePath();
          } else {
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

    protected static ResourceReference getLocalRoot(ResourceReference rr_root,
                ResourceReference ref)
    {
  try {
      FramedResource root = (FramedResource)rr_root.lock();
      if (root instanceof VirtualHostResource) {
    //backward to the virtual host resource
    ResourceReference rr  = null;
    ResourceReference rrp = null;
    FramedResource    res = null;
    try {
        res = (FramedResource)ref.lock();
        if (res instanceof ResourceFrame) {
      ResourceFrame fr = (ResourceFrame)res;
      rr = fr.getResource().getResourceReference();
        } else {
      rr = ref;
        }
    } catch (InvalidResourceException ex) {
        return rr_root;
    } finally {
        ref.unlock();
    }

    while (true) {
        try {
      res = (FramedResource)rr.lock();
      rrp = res.getParent();
      if ((rrp == rr_root) || (rrp == null)) {
          return getLocalRoot(rr, ref);
      }
        } catch (InvalidResourceException ex) {
      return rr_root;
        } finally {
      rr.unlock();
        }
        rr = rrp;
    }
      } else {
    try {
        FramedResource res = (FramedResource)rr_root.lock();
        ForwardFrame   ffr = (ForwardFrame)
      res.getFrame("org.w3c.jigsaw.proxy.ForwardFrame");
        if (ffr == null) {
      return rr_root;
        } else {
      ResourceReference rr = ffr.getLocalRootResource();
      return getLocalRoot(rr, ref);
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

  //first, find the ServletDirectoryFrame.
  // Prepare for lookup:
  ResourceReference rr_root = null;
  rr_root = ((httpd) getServer()).getRootReference();

  FramedResource root = null;
  root = ((httpd) getServer()).getRoot();

  // 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
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

      if (! (res instanceof ServletDirectoryFrame)) {
    throw new IllegalArgumentException("This reference is not "+
              "pointing on a ServletDirectoryFrame.");
      } else {
    ServletDirectoryFrame sframe = (ServletDirectoryFrame)res;
    FramedResource resource = (FramedResource)sframe.getResource();
    resource.addStructureChangedListener(this);
    if (resource.definesAttribute("directory"))
        this.directory =
      (File) resource.getValue("directory", null);
      }
  } catch(InvalidResourceException ex) {
      throw new IllegalArgumentException("This reference is pointing on"+
                 " an Invalid ServletDirectoryFrame.");
  } finally {
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

  return rr;
    }

    private synchronized FramedResource changeRoot(String name) {
  ResourceReference newroot = loadRoot(name);
  FramedResource oldroot = this.root;
  String oldroot_name = this.root_name;
  if ( newroot != null ) {
      try {
    this.root      = (FramedResource)newroot.lock();
    this.root_name = name;
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

        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 {
    // temporary target resource !!! WARNING
    request.setTargetResource(target);
    if ( filters != null ) {
        for ( ; infilter < filters.length ; infilter++ ) {
      if ( filters[infilter] == null )
          continue;
      reply = (Reply)filters[infilter].
                                     ingoingFilter(request,
                     filters,
                     infilter);
      if ( reply != null ) {
          return reply;
      }
        }
    }
      } catch (ProtocolException ex) {
    error = ex;
      }
      //perform the request:
      if ((error == null) && (target != null)) {
    request.setFilters(filters, infilter);
    request.setTargetResource(target);
    try {
        FramedResource res = (FramedResource)target.lock();
        reply = (Reply) res.perform(request);
        if (reply == null) {
      reply = request.makeReply(HTTP.NOT_FOUND);
      if (uri_error) {
          reply.setContent("<html><head><title>Not Found" +
               "</title></head>\n"+
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

    protected synchronized void writelog(String record) {
  try {
      if ( log != null )
    log.writeBytes(record);
  } catch (IOException ex) {
      FramedResource target = (FramedResource) getTargetResource();
      if (target != null) {
    String msg = ("IO error while writing to log file \""+
            ex.getMessage() + "\".");
    target.getServer().errlog(this, msg);
      }
  }
    }
View Full Code Here

Examples of org.w3c.tools.resources.FramedResource

      }
  } catch (Exception ex) {
  }
  // If failed, emit error message:
  if ( log == null ) {
      FramedResource target = (FramedResource) getTargetResource();
      if (target != null) {
    String msg = ("unable to open log file \""+
            logfile
            + "\".");
    target.getServer().errlog(this, msg);
      }
  }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.