Package org.w3c.tools.resources

Examples of org.w3c.tools.resources.DirectoryResource


    String indexes[] = getIndexes();
    if (indexes != null) {
        for (int i = 0 ; i < indexes.length ; i++) {
      String index = indexes[i];
      if ( index != null && index.length() > 0) {
          DirectoryResource dir =
        (DirectoryResource) resource;
          ResourceReference rr = dir.lookup(index);
          if (rr != null) {
        try {
            FramedResource rindex =
          (FramedResource) rr.lock();
            return rindex.lookup(ls,lr);
View Full Code Here


    if (action.equals("remove")) {
        //get the parent resource of our own resource
        ResourceReference rr = getResource().getParent();
        try {
      Resource res = rr.lock();
      DirectoryResource dirres = null;
      if (! (res instanceof DirectoryResource)) {
          getServer().errlog(res,
             "CvsFrame: not a child of a DirectoryResource");
          return error(this, request,
         "The server is misconfigured.",
         "The CVS Directory is not a children of a"+
         "Directory Resource.");
      }
      dirres = (DirectoryResource) res;
      for (int i=0; i < size; i++ ) {
          String name = names[i];
          ResourceReference childref = dirres.lookup(name);
          if (childref != null) {
        try {
            Resource children = childref.lock();
            if (children instanceof FileResource) {
          FileResource fres =
              (FileResource) children;
          // delete the file
          fres.getFile().delete();
          // delete the resource
          fres.delete();
            }
        } catch(MultipleLockException mex) {
            mex.printStackTrace();
            return error(this, request,
             "MultipleLockException: "+
             mex.getMessage(),
             "Resource "+name+" in use"+
             ", can't be deleted now.");
        } catch(InvalidResourceException iex) {
            iex.printStackTrace();
            return error(this, request,
             "InvalidResourceException. ",
             iex.getMessage());
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(this, request,
             "Exception occurs.",
             ex.getMessage());
        } finally {
            childref.unlock();
        }
          } else {
        //no resource, remove the file only
        File file = new File( dirres.getDirectory(),
                  name );
        file.delete();
          }
      }
        } catch(InvalidResourceException ex) {
View Full Code Here

     */
    protected Reply getDirectoryResource(Request request)
  throws ProtocolException, ResourceException
    {
  // get our associated DirectoryResource
  DirectoryResource dres = getDirectoryResource();
  // Create the HTML generator, and set titles:
  HtmlGenerator g = new HtmlGenerator("FancyFrame");
  g.append("<h1>FancyFrame output</h1>");
  // emit the message
  g.append("<p>",getMessage(),"</p>");
  // display information about our DirectoryResource
  g.append("<h2> DirectoryResource associated : </h2>");
  g.append("<ul><li>Identifier : ",dres.getIdentifier());
  g.append("<li>Directory : "+dres.getDirectory());
  g.append("<li>Last Modified Time : ",
     new Date(dres.getLastModified()).toString(),
     "</ul>");
  // now emit the reply
  Reply reply = createDefaultReply(request, HTTP.OK) ;
  reply.setStream(g) ;
  return reply ;
View Full Code Here

  Vector checked = new Vector(variants.length) ;
  ResourceReference tmpres = null;
  ResourceReference r_parent   = resource.getParent() ;
  try {
      DirectoryResource parent= (DirectoryResource)r_parent.unsafeLock();
      for (int i = 0 ; i < variants.length ; i++) {
    tmpres = parent.lookup(variants[i]) ;
    if (tmpres != null) {
        try {
      FramedResource resource =
            (FramedResource)tmpres.unsafeLock() ;
      NegotiatedFrame itsframe = (NegotiatedFrame)
View Full Code Here

  // Look them up in our parent directory:
  ResourceReference variants[] = new ResourceReference[names.length] ;
  ResourceReference r_parent   = resource.getParent() ;
  try {
      DirectoryResource parent= (DirectoryResource)r_parent.unsafeLock();
      int missing = 0;
      for (int i = 0 ; i < names.length ; i++) {
    variants[i] = parent.lookup(names[i]) ;
    if (variants[i] == null)
        missing++;
      }
      if (missing > 0) {
    int kept = names.length - missing;
View Full Code Here

      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;
          return dir.getDirectory().getAbsolutePath();
          //return getFilePath(dir);
      }
        } finally {
      target.unlock();
        }
View Full Code Here

    String indexes[] = getIndexes();
    if (indexes != null) {
        for (int i = 0 ; i < indexes.length ; i++) {
      String index = indexes[i];
      if ( index != null && index.length() > 0) {
          DirectoryResource dir =
        (DirectoryResource) resource;
          ResourceReference rr = dir.lookup(index);
          if (rr != null) {
        try {
            FramedResource rindex =
          (FramedResource) rr.lock();
            return rindex.lookup(ls,lr);
View Full Code Here

     * @exception ResourceException if a server error occurs
     */
    public synchronized Reply getDirectoryListing(Request request)
  throws ProtocolException, ResourceException
    {
  DirectoryResource dirResource = null;
  try {
      dirResource = (DirectoryResource) getDirResourceRef().lock();
      if (dirResource == null)
    throw new ResourceException("parent is NOT a "+
              "DirectoryResource. ("+
              resource.getIdentifier()+")");
      if (! dirResource.verify()) {
    // the directory was deleted, but we can't delete it here
    // (Multiple Locks)
    // Emit an error back:
    Reply error = request.makeReply(HTTP.NOT_FOUND) ;
    error.setContent ("<h1>Document not found</h1>"+
          "<p>The document "+
          request.getURL()+
          " is indexed but not available."+
          "<p>The server is misconfigured.") ;
    throw new HTTPException (error) ;
      }
      // Have we already an up-to-date computed a listing ?
      if ((listing == null)
    || (dirResource.getDirectory().lastModified() > listing_stamp)
    || (dirResource.getLastModified() > listing_stamp)
    || (getLastModified() > listing_stamp)) {
   
    Enumeration e = dirResource.enumerateResourceIdentifiers() ;
    Vector        resources = Sorter.sortStringEnumeration(e) ;
    HtmlGenerator g = new HtmlGenerator("Directory listing of "+
              dirResource.getIdentifier());
    // Add style link
    addStyleSheet(g);
    g.append("<h1>Directory listing of ",
       dirResource.getIdentifier(),
       "</h1>");
    // Link to the parent, when possible:
    if ( dirResource.getParent() != null )
        g.append("<p><a href=\"..\">Parent</a><br>");
    g.append("\n<form method=\"POST\" action=\""+request.getURL()
       +"\">\n");
    String listername = getResource().getIdentifier();
    // List the children:
    g.append("<table border=\"0\">\n");

    ResourceReference rr       = null;
    FramedResource    resource = null;
    String            name     = null;
    //ugly hack to put CVS link first
    rr = dirResource.lookup("CVS");
    if (rr != null) {
        g.append(getResourceLine(rr, "CVS", false));
    }
    boolean even = true;
    for (int i = 0 ; i < resources.size() ; i++) {
        name = (String) resources.elementAt(i);
        if ( name.equals(listername) || name.equals("CVS"))
      continue;
        rr = dirResource.lookup(name);
        g.append(getResourceLine(rr, name, even));
        even = !even;
    }
    g.append("</table>\n");
    g.append("<P><INPUT TYPE=\"SUBMIT\" NAME=\"SUBMIT\" VALUE=\""+
View Full Code Here

      if (name.equals("SUBMIT"))
    continue;
      // delete file now... avoit deleting CVS and lister
      // (should be in an attribute)
      synchronized (this) {
    DirectoryResource dr;
    Resource toDeleteRes;
    ResourceReference rr;
    File dir, toDeleteFile;
    try {
        dr = (DirectoryResource) getDirResourceRef().lock();
        dir = dr.getDirectory();
        if (debug)
      System.out.println("Deleting " + name);
        rr = dr.lookup(name);
        if (rr != null) {
      try {
          toDeleteFile = new File(dir, name);
          toDeleteFile.delete();
      } catch (Exception ex) {
View Full Code Here

    // return the index file.
    String index = getIndex();
    if ( index != null && index.length() > 0) {
        ResourceReference root = getLocalRootResource();
        try {
      DirectoryResource dir =
          (DirectoryResource)root.lock();
      ResourceReference rr = dir.lookup(index);
      if (rr != null) {
          try {
        FramedResource rindex =
            (FramedResource) rr.lock();
        return rindex.lookup(ls,lr);
View Full Code Here

TOP

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

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.