Package org.w3c.tools.resources

Examples of org.w3c.tools.resources.LookupState


    public ResourceReference lookup(Request request)
  throws ProtocolException
    {
  // Create lookup state and get rid of root resource requests:
  LookupState   ls = null;
  try {
      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:
  String name = ls.getNextComponent();
  ServerHandler sh = shm.lookupServerHandler(name);
  if ( sh == null ) {
      if(name.equals("realms")) {
    rr = admin.getRealmCatalogResource();
      } else if (name.equals("control")) {
    rr = admin.getControlResource();
      } else {
    error(request, "unknown server handler");
      }
  } else {
      // Lookup that resource, from the config resource of that server:
      rr = sh.getConfigResource();
  }
  if ( rr != null ) {
      ResourceReference rr_temp = null;
      while ( ls.hasMoreComponents() ) {
    try {
        if (rr == null)
      error(request, "url too long");
        Resource r = rr.lock();
        if ( ! ( r instanceof ContainerInterface) )
      error(request, "url too long");
        rr_temp = ((ContainerInterface) r).lookup(
                   ls.getNextComponent());
    } catch (InvalidResourceException ex) {
        error(request, "unable to restore resource");
    } finally {
        rr.unlock();
        rr = rr_temp;
View Full Code Here


        httpd server =
      (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) {
View Full Code Here

  try {
      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;
View Full Code Here

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

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

      errlog("checkpointer URL unknown.");
      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 {
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();
      }
View Full Code Here

    protected ResourceReference getServletDirectoryReference(httpd server) {
  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) {
View Full Code Here

  ResourceReference rr = server.getEditRoot();
  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) {
View Full Code Here

  if ( u == null )
      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;
View Full Code Here

TOP

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

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.