You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by cm...@apache.org on 2002/03/02 18:38:37 UTC

cvs commit: jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/util SPUtils.java

cmlenz      02/03/02 09:38:37

  Modified:    src/contrib/webdavgui Tag: SLIDE_1_0 build.xml
               src/contrib/webdavgui/src/bin Tag: SLIDE_1_0 runui.bat
                        runui.sh
               src/contrib/webdavgui/src/java/org/apache/webdav/ui Tag:
                        SLIDE_1_0 SPWebdavClient.java
               src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser
                        Tag: SLIDE_1_0 SPFileChooser.java SPFileFilter.java
                        SPFileView.java
               src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir
                        Tag: SLIDE_1_0 SPDirectoryService.java SPFile.java
                        SPResourceNode.java SPWebFile.java SPWebFolder.java
               src/contrib/webdavgui/src/java/org/apache/webdav/ui/lab Tag:
                        SLIDE_1_0 HostFrame.java
               src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods
                        Tag: SLIDE_1_0 SPLockMethod.java
                        SPPropFindMethod.java SPPropPatchMethod.java
                        SPPutMethod.java SPUnlockMethod.java
               src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties
                        Tag: SLIDE_1_0 LockdiscoveryProperty.java
                        SPProperty.java
  Removed:     src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties
                        Tag: SLIDE_1_0 WebdavProperty.java
               src/contrib/webdavgui/src/java/org/apache/webdav/ui/util
                        Tag: SLIDE_1_0 SPUtils.java
  Log:
  Porting bugfixes/enhancements from the HEAD branch:
  - Committed by msmith, 02/02/04 15:49:14
    "Updates to webdav gui code to a) fix some bugs revealed by current server,
     and b) work with jdk 1.4"
  - Committed by msmith, 02/02/07 20:24:06
    "Fairly major changes to make filechooser more intelligent in use of webdav
     (to avoid extra webdav requests, which are potentially slow over a slow
     network)."
  - Committed by msmith, 02/02/11 21:41:59
    "More updates (mostly for bugfixes)"
  - Committed by msmith, 02/02/11 22:34:32
    "Final round of bugfixes (property handling mistakes)."
  - Committed by msmith, 02/02/20 21:54:41
    "This file was supposedly removed."
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +24 -1     jakarta-slide/src/contrib/webdavgui/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- build.xml	25 Jul 2001 06:12:37 -0000	1.3
  +++ build.xml	2 Mar 2002 17:38:36 -0000	1.3.2.1
  @@ -1,4 +1,4 @@
  -<project name="Slide" default="main" basedir=".">
  +<project name="Slide" default="dist" basedir=".">
   
   
     <!-- =================================================================== -->
  @@ -96,6 +96,7 @@
       <pathelement location="${xmlapi.jar}"/>
       <pathelement location="${httpclient.jar}"/>
       <pathelement location="${slide.build}/classes"/>
  +    <pathelement location="${slide.build}/client/classes"/>
     </path>
   
   
  @@ -235,6 +236,27 @@
   
     </target>
   
  +  <target name="dist-prepare">
  +    <mkdir dir="${webdavclient.dist}" />
  +    <mkdir dir="${webdavclient.dist}/bin" />
  +    <mkdir dir="${webdavclient.dist}/lib" />
  +  </target>
  +
  +  <target name="dist" depends="prepare, main, dist-prepare">
  +    <copy todir="${webdavclient.dist}/bin">
  +      <fileset dir="src/bin">
  +        <include name="**/*.bat" />
  +        <include name="**/*.sh" />
  +      </fileset>
  +    </copy>
  +    <jar jarfile="${webdavclient.dist}/lib/webdavgui.jar"
  +         basedir="${webdavclient.build}/classes"
  +         includes="org/apache/webdav/ui/**,images/**">
  +    </jar>
  +  </target>
  +
  +
  +
   
     <!-- =================================================================== -->
     <!-- Clean build and distribution directories of the DAV client          -->
  @@ -242,6 +264,7 @@
     <target name="clean">
       <delete dir="${webdavclient.build}/classes/images"/>
       <delete dir="${webdavclient.build}/classes/org/apache/webdav/ui"/>
  +    <delete file="${webdavclient.dist}/lib/webdavgui.jar"/>
     </target>
   
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +2 -2      jakarta-slide/src/contrib/webdavgui/src/bin/runui.bat
  
  Index: runui.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/bin/runui.bat,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- runui.bat	1 Sep 2001 17:36:12 -0000	1.3
  +++ runui.bat	2 Mar 2002 17:38:36 -0000	1.3.2.1
  @@ -1,3 +1,3 @@
   @echo off
  -set CP2=%CLASSPATH%;./classes/;./lib/webdav.jar;./lib/jaxp.jar;./lib/crimson.jar;./lib/commons-httpclient.jar
  -java -classpath %CP2% org.apache.webdav.ui.lab.Launcher %1 %2 %3 %4 %5 %6 %7 %8 %9
  \ No newline at end of file
  +set CP2=%CLASSPATH%;./lib/webdavgui.jar;./classes/;./lib/slide-webdavlib.jar;./lib/jaxp.jar;./lib/crimson.jar;./lib/commons-httpclient.jar
  +java -classpath %CP2% org.apache.webdav.ui.lab.Launcher %1 %2 %3 %4 %5 %6 %7 %8 %9
  
  
  
  1.3.2.1   +2 -2      jakarta-slide/src/contrib/webdavgui/src/bin/runui.sh
  
  Index: runui.sh
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/bin/runui.sh,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- runui.sh	1 Sep 2001 17:36:12 -0000	1.3
  +++ runui.sh	2 Mar 2002 17:38:36 -0000	1.3.2.1
  @@ -3,8 +3,8 @@
   # Helper to run the command line client
   #
    
  -CLASSPATH=${CLASSPATH}:../classes:../lib/webdav.jar:../lib/jaxp.jar:../lib/crimson.jar:../lib/commons-httpclient.jar
  +CLASSPATH=${CLASSPATH}:../classes:../lib/webdavgui.jar:../lib/slide-webdavlib.jar:../lib/jaxp.jar:../lib/crimson.jar:../lib/commons-httpclient.jar
   
   export CLASSPATH
   
  -java org.apache.webdav.ui.lab.Launcher $*
  \ No newline at end of file
  +java org.apache.webdav.ui.lab.Launcher $*
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +0 -17     jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/SPWebdavClient.java
  
  Index: SPWebdavClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/SPWebdavClient.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- SPWebdavClient.java	17 Jul 2001 04:00:45 -0000	1.1
  +++ SPWebdavClient.java	2 Mar 2002 17:38:36 -0000	1.1.2.1
  @@ -6,7 +6,6 @@
   
   import org.apache.webdav.ui.lib.properties.*;
   import org.apache.webdav.lib.methods.*;
  -import org.apache.webdav.ui.util.SPUtils;
   
   import org.apache.commons.httpclient.*;
   
  @@ -25,22 +24,6 @@
   
     public String getSessionPort()  {
       return String.valueOf(this.sessionPort);
  -  }
  -
  -  public Credentials getCredentials() {
  -    return credentials;
  -  }
  -
  -  public String getLockToken(String uri)  {
  -    String lockToken = null;
  -
  -    LockdiscoveryProperty lockdiscoveryProp =
  -        (LockdiscoveryProperty) SPUtils.getProperty(this, uri, "lockdiscovery");
  -    if (lockdiscoveryProp != null)  {
  -        lockToken = lockdiscoveryProp.getLockToken(credentials.getUserName());
  -    }
  -
  -    return lockToken;
     }
   
   } //End of SPWebdavClient class
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +19 -3     jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java
  
  Index: SPFileChooser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SPFileChooser.java	17 Jul 2001 04:00:46 -0000	1.2
  +++ SPFileChooser.java	2 Mar 2002 17:38:36 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java,v 1.2 2001/07/17 04:00:46 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:46 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java,v 1.2.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -102,6 +102,22 @@
               SPFileSystemView fileSystemView =
   		    new SPFileSystemView(directoryService);
   	    SPFileChooser fileChooser = new SPFileChooser(fileSystemView);
  +            return fileChooser;
  +
  +        } catch (Exception e) {
  +            throw e;
  +        }
  +    }
  +
  +    public static SPFileChooser createWebFileChooser(HttpClient client,
  +        String rootUrlPath, SPDirectoryService service) throws Exception {
  +
  +        try {
  +            directoryService = (service==null)?(new SPDirectoryService(
  +                        client, rootUrlPath)):service;
  +            SPFileSystemView fileSystemView =
  +            new SPFileSystemView(directoryService);
  +        SPFileChooser fileChooser = new SPFileChooser(fileSystemView);
               return fileChooser;
   
           } catch (Exception e) {
  
  
  
  1.2.2.1   +3 -4      jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java
  
  Index: SPFileFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SPFileFilter.java	17 Jul 2001 04:00:46 -0000	1.2
  +++ SPFileFilter.java	2 Mar 2002 17:38:36 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java,v 1.2 2001/07/17 04:00:46 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:46 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java,v 1.2.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -69,7 +69,6 @@
   import javax.swing.filechooser.FileFilter;
   
   import org.apache.webdav.ui.filechooser.dir.SPFile;
  -import org.apache.webdav.ui.util.SPUtils;
   
   /**
    * Title:        SPFileFilter.java
  
  
  
  1.2.2.1   +8 -5      jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileView.java
  
  Index: SPFileView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileView.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SPFileView.java	17 Jul 2001 04:00:46 -0000	1.2
  +++ SPFileView.java	2 Mar 2002 17:38:36 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileView.java,v 1.2 2001/07/17 04:00:46 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:46 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileView.java,v 1.2.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -167,7 +167,7 @@
   
       SPFile f = (SPFile) aFile;
   
  -    boolean isReadOnly = f.getReadOnlyCached();
  +    boolean isReadOnly = f.isLockedByOthers();
       boolean noWriteAccess = ! f.hasWriteAccess();
   
       if (noWriteAccess || isReadOnly) {
  @@ -183,9 +183,12 @@
     public Icon getIcon(File aFile) {
       ImageIcon icon = this.unknownIcon;
   
  +    if (!(aFile instanceof SPFile))
  +        return icon;
  +
       SPFile f = (SPFile) aFile;
       int type = f.getType();
  -    boolean isReadOnly = f.getReadOnlyCached();
  +    boolean isReadOnly = f.isLockedByOthers();
       boolean noWriteAccess = ! f.hasWriteAccess();
   
       if (noWriteAccess || isReadOnly) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +6 -10     jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java
  
  Index: SPDirectoryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- SPDirectoryService.java	18 Oct 2001 00:15:00 -0000	1.3
  +++ SPDirectoryService.java	2 Mar 2002 17:38:36 -0000	1.3.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java,v 1.3 2001/10/18 00:15:00 msmith Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/10/18 00:15:00 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java,v 1.3.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.3.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -69,7 +69,6 @@
   
   import org.apache.webdav.lib.*;
   import org.apache.webdav.ui.lib.methods.SPPropFindMethod;
  -import org.apache.webdav.ui.util.SPUtils;
   
   import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.HttpStatus;
  @@ -281,12 +280,9 @@
   	    if (parentDir.hasWriteAccess())   {
   		SPWebFile newNode = new SPWebFile(client,
   		    parentUrlPath+aFile.getName());
  -		int statusCode = newNode.putFileContent("");
  -		if ( statusCode>=200 && statusCode < 300) {
  -		    parentDir.addWebFile(newNode);
  -		    this.fileCache.put(aFile, newNode);
  -		    theNode = (SPResourceNode) newNode;
  -		}
  +	        parentDir.addWebFile(newNode);
  +		this.fileCache.put(aFile, newNode);
  +		theNode = (SPResourceNode) newNode;
   	    } else {
   		throw new HttpException("Write Access Denied in "
   		        +parentUrlPath+" ("+HttpStatus.SC_FORBIDDEN+")");
  
  
  
  1.3.2.1   +76 -26    jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java
  
  Index: SPFile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- SPFile.java	1 Aug 2001 01:25:54 -0000	1.3
  +++ SPFile.java	2 Mar 2002 17:38:36 -0000	1.3.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java,v 1.3 2001/08/01 01:25:54 msmith Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/08/01 01:25:54 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java,v 1.3.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.3.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -69,10 +69,10 @@
   
   import org.apache.webdav.lib.*;
   import org.apache.webdav.lib.properties.*;
  -import org.apache.webdav.ui.util.SPUtils;
   
   import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.HttpStatus;
  +import org.apache.commons.httpclient.HttpClient;
   
   /**
    * Title:        SPFile.java
  @@ -84,7 +84,8 @@
   
   public class SPFile extends File {
       private SPDirectoryService directoryService;
  -
  +    private SPResourceNode _resourceNode;
  +    
       public SPFile(String pathname, SPDirectoryService directoryService) {
         super(pathname);
         this.directoryService = directoryService;
  @@ -102,6 +103,12 @@
         this.directoryService = directoryService;
       }
   
  +    // Constructor that is Directory service independent
  +    public SPFile(String pathname, SPResourceNode resource) {
  +        super(pathname);
  +        _resourceNode = resource;
  +    }
  +
      /*
       * Determines if the file should be displayed
       * based on the current filter.
  @@ -135,11 +142,15 @@
        */
   
       public boolean isDirectory() {
  -	if (exists())  {
  -	    return ( getResourceNode().isWebFolder() );
  -	}
  -
  -	return false;
  +        if (_resourceNode!=null)
  +            return _resourceNode.isWebFolder();
  +        else {
  +            SPResourceNode node = directoryService.getNodeFromCache(this);
  +            if(node != null)
  +                return node.isWebFolder();
  +            else
  +                return false;
  +        }
       }
   
       public boolean isFile() {
  @@ -160,12 +171,12 @@
         return getResourceNode().isLocked();
       }
   
  -    public boolean isReadOnly() {
  -      return getResourceNode().isReadOnly();
  +    public boolean isLockedByOthers() {
  +      return getResourceNode().isLockedByOthers();
       }
   
  -    public boolean getReadOnlyCached()  {
  -      return getResourceNode().getReadOnlyCached();
  +    public boolean isLockedByOthersNotCached() {
  +      return getResourceNode().isLockedByOthersNotCached();
       }
   
       public boolean hasReadAccess()  {
  @@ -185,27 +196,38 @@
       }
   
       public boolean equals(Object obj) {
  -	if (obj == null)  {
  -	    return false;
  -	}
  -
  -	SPFile objFile = (SPFile) obj;
  -        return ( (directoryService == objFile.getDirectoryService())
  -	     && (super.equals(obj)) );
  +	    if (obj == null)  {
  +	        return false;
  +	    }
  +
  +        if (!(obj instanceof SPFile))
  +            return false;
  +
  +	    SPFile objFile = (SPFile) obj;
  +        if (directoryService!=null)
  +            return ( (directoryService == objFile.getDirectoryService())
  +	                 && (super.equals(obj)) );
  +        else
  +            return super.equals(obj);
       }
   
       public String getResourceUrlPath()  {
           return (getResourceNode().getResourceUrlPath());
       }
       public File getParentFile() {
  -	if (this.equals(directoryService.getRoot()))  {
  +	if (directoryService!=null && this.equals(directoryService.getRoot()))  {
   	    return this;
   	}
   
   	String absPath = getAbsolutePath();
   	absPath = absPath.substring(0, absPath.lastIndexOf(File.separator));
   
  -	return new SPFile(absPath, directoryService);
  +    if (directoryService!=null)
  +	    return new SPFile(absPath, directoryService);
  +    else {
  +        System.err.println("ERROR: Getting parent _without_ directoryService, can't do this at the moment!");
  +        return null;
  +    }
       }
   
      /*
  @@ -218,14 +240,17 @@
   
       public long getContentLength()  {
           GetContentLengthProperty prop = (GetContentLengthProperty)
  -	    SPUtils.getProperty(getResourceNode(), "getcontentlength");
  -	return prop.getLength();
  +	            getResourceNode().getProperty("getcontentlength");
  +	    return prop.getLength();
       }
   
       /*
        * Returns null if the resource node is not found in server
        */
       public SPResourceNode getResourceNode()  {
  +        if (_resourceNode!=null)
  +            return _resourceNode;
  +
   	SPResourceNode theNode=null;
   
           try {
  @@ -361,6 +386,26 @@
   
     }
   
  +  /* FIXME: The method below, that takes only a File object, will create the 
  +     file (doing a PUT of a zero-length object) before putting this file, if
  +     the file doesn't already exist). This is pretty silly behaviour, 
  +     so we want a more intelligent one.
  +     However, this doesn't work right - rather than track it all down for
  +     now, we just call the more inefficient one.
  +   */
  +  public int putWebFileContent(HttpClient client, File aFile) 
  +        throws Exception {
  +      /*
  +      SPResourceNode thisNode = getResourceNode();
  +
  +      if(thisNode == null)
  +          thisNode = new SPWebFile(client, getAbsolutePath());
  +      
  +      return ((SPWebFile)thisNode).putFileContent(aFile);
  +      */
  +      return putWebFileContent(aFile);      
  +  }
  +
     public int putWebFileContent(File aFile) throws Exception  {
       SPResourceNode thisNode = getResourceNode();
   
  @@ -386,7 +431,12 @@
     }
   
     private String getExtension() {
  -    return SPUtils.getExtension(getName());
  +      int i = getName().lastIndexOf(".");
  +
  +      if (i > 0 && i < getName().length() - 1)
  +          return getName().substring(i+1).toLowerCase();
  +      else
  +          return null;
     }
   
   } //End of SPFile class
  
  
  
  1.2.2.1   +371 -65   jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java
  
  Index: SPResourceNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SPResourceNode.java	17 Jul 2001 04:00:47 -0000	1.2
  +++ SPResourceNode.java	2 Mar 2002 17:38:36 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java,v 1.2 2001/07/17 04:00:47 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:47 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java,v 1.2.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -64,12 +64,25 @@
   package org.apache.webdav.ui.filechooser.dir;
   
   import java.util.List;
  +import java.util.Vector;
  +import java.util.Hashtable;
  +import java.util.Enumeration;
  +import java.util.Iterator;
  +import java.io.IOException;
  +
  +import javax.swing.JOptionPane;
   
   import org.apache.webdav.ui.lib.properties.*;
   import org.apache.webdav.lib.*;
  -import org.apache.webdav.ui.util.SPUtils;
  +import org.apache.webdav.lib.methods.DepthSupport;
  +import org.apache.webdav.ui.lib.methods.SPLockMethod;
  +import org.apache.webdav.ui.lib.methods.SPUnlockMethod;
  +import org.apache.webdav.ui.lib.methods.SPPropFindMethod;
  +import org.apache.webdav.ui.lib.methods.SPPropPatchMethod;
   
  +import org.apache.commons.httpclient.HttpStatus;
   import org.apache.commons.httpclient.HttpClient;
  +import org.apache.commons.httpclient.HttpException;
   
   /**
    * Title:        SPResourceNode.java
  @@ -87,20 +100,40 @@
     protected HttpClient client;
     protected String resourceUrlPath=null;
     protected String name=null;
  +  protected String lockToken = null;
  +
  +  protected Hashtable cachedProperties = new Hashtable();
   
  -  /* readAccess and writeAccess fields are this node's access privilege.
  -   *
  -   * readOnlyCached is a cache for this node's read only mode. This field
  -   * is used by SPFileChooser when refreshing the content of a folder.
  -   * When a current state of read only mode is desired, the user must call
  -   * the isReadOnly() instead.
  -   */
  -  protected boolean readAccess=false, writeAccess=false,
  -                    readOnlyCached=false, accessPrivilegeChecked=false;
     protected SPWebFolder parentNode=null;
   
     public abstract List getChildren();
   
  +  public void addCachedProperties(Enumeration props, Vector propnames) {
  +      while(props.hasMoreElements())
  +      {
  +          Property prop = (Property)props.nextElement();
  +
  +          SPProperty spProp = SPProperty.factory(prop);
  +
  +          cachedProperties.put(spProp.getName(), 
  +                  new PropertiesCacheEntry(spProp));
  +          propnames.remove(spProp.getName());
  +      }
  +
  +      /* Ok. Now propnames contains those propnames which did NOT have
  +       * corresponding properties in the enumeration. This occurs if the
  +       * property was requested in the PROPFIND, but didn't exist. 
  +       * Since we _have_ checked for it, though, we want to explicitly
  +       * cache the fact that it doesn't exist.
  +       */
  +      Enumeration nullProps = propnames.elements();
  +
  +      while(nullProps.hasMoreElements()) {
  +          String propname = (String)nullProps.nextElement();
  +          cachedProperties.put(propname, new PropertiesCacheEntry(null));
  +      }
  +  }
  +
     public String getName() {
       return name;
     }
  @@ -109,18 +142,35 @@
       this.name = newName;
     }
   
  -  public void setReadOnlyCached(boolean b)  {
  -    this.readOnlyCached = b;
  -  }
  -
  -  public boolean getReadOnlyCached()  {
  -    return readOnlyCached;
  +  public boolean isLockedByOthers() {
  +      if(lockToken != null)
  +          return false;
  +
  +	  LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
  +              "lockdiscovery");
  +      if(prop != null && prop.getActiveLock(
  +                  getClient().getCredentials().getUserName()) == null) {
  +          return true;
  +      }
  +      else
  +          return false;
     }
   
     public SPResourceNode getParent()  {
       if (parentNode == null)  {
  -        parentNode = new SPWebFolder(client,
  -	    SPUtils.getParentUrl(resourceUrlPath));
  +        String parentUrlPath = resourceUrlPath;
  +
  +        if(!parentUrlPath.startsWith("/"))
  +            parentUrlPath = "/" + parentUrlPath;
  +
  +        if(parentUrlPath.length() > 1) {
  +            if(parentUrlPath.endsWith("/"))
  +                parentUrlPath = parentUrlPath.substring(
  +                        0, parentUrlPath.length()-1);
  +            parentUrlPath = parentUrlPath.substring(
  +                    0, parentUrlPath.lastIndexOf("/") + 1);
  +        }
  +        parentNode = new SPWebFolder(client, parentUrlPath);
       }
       return parentNode;
     }
  @@ -146,33 +196,254 @@
     }
   
     public boolean isLocked() {
  -    return SPUtils.isLocked(this);
  -  }
  -
  -  public boolean isReadOnly() {
  -    return SPUtils.isReadOnly(this);
  +      LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
  +              "lockdiscovery");
  +      return prop!=null;
  +  }
  +
  +  public boolean isLockedByOthersNotCached() { 
  +      if(lockToken != null) {
  +          return false;
  +      }
  +      LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
  +              "lockdiscovery", true);
  +      if(prop != null && prop.getActiveLock(
  +                  getClient().getCredentials().getUserName()) == null) {
  +          return true;
  +      }
  +      else
  +          return false;
     }
   
     public String lock()  {
  -    return SPUtils.lock(this);
  +    return lock(DEFAULT_TIMEOUT);
     }
   
     public String lock(long timeout)  {
  -    return SPUtils.lock(this, timeout);
  -  }
  +      try {
  +          SPLockMethod method;
   
  -  public boolean unlock()  {
  -    return SPUtils.unlock(this);
  +          if(lockToken == null) {
  +              LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
  +                    "lockdiscovery");
  +              if(prop != null) {
  +                  // This may return null, meaning someone else has it locked.
  +                 lockToken = prop.getLockToken(
  +                         getClient().getCredentials().getUserName());
  +              }
  +          }
  +
  +          if(lockToken != null) /* Refresh the lock */ {
  +              method = new SPLockMethod(this, lockToken, timeout);
  +          }
  +          else /* New lock */ {
  +              method = new SPLockMethod(this, timeout);
  +          }
  +
  +          method.execute();
  +          int status = method.getStatusCode();
  +          
  +          if(status == HttpStatus.SC_OK) {
  +              lockToken = method.getLockToken();
  +          }
  +          else if(status == HttpStatus.SC_LOCKED)
  +              showErrorMessage("Locking Failure",
  +                      "Unable to lock resource.\n"+
  +                      "The resource \""+method.getPath()+"\" is currently "+
  +                      "locked by another user.");
  +          else
  +              showErrorMessage("Locking Failure",
  +                      "Unable to lock resource \""+method.getPath()+"\": "+
  +                      status+".");
  +      }
  +      catch(HttpException e) {
  +          e.printStackTrace();
  +      }
  +      catch(IOException e) {
  +          e.printStackTrace();
  +      }
  +
  +      return lockToken;
     }
   
  -  public SPProperty getProperty(String propertyName)  {
  -    return SPUtils.getProperty(this, propertyName);
  +  public boolean unlock()  {
  +      SPUnlockMethod method;
  +      if(lockToken != null) {
  +          method = new SPUnlockMethod(this, lockToken);
  +      }
  +      else {
  +          System.out.println("ERROR: Unlock() without a known locktoken!");
  +          method = null;
  +          /* FIXME: What should we do here - unlock without a lock token
  +           * known.
  +           */
  +      }
  +      lockToken = null;
  +      cachedProperties.remove("lockdiscovery");
  +
  +      try {
  +          method.execute();
  +          int status = method.getStatusCode();
  +
  +          System.out.println("Unlock status: "+status);
  +          if(status != HttpStatus.SC_NO_CONTENT) {
  +              showErrorMessage("Unlocking Failure",
  +                      "Unable to unlock resource \""+method.getPath()+
  +                      "\": "+status+".");
  +              return false;
  +          }
  +          else
  +              return true;
  +      } catch(Exception e) {
  +          e.printStackTrace();
  +      } 
  +      return false;
  +  }
  +
  +  public SPProperty getProperty(String propertyName) {
  +      return getProperty(propertyName, false);
  +  }
  +
  +  public SPProperty getProperty(String property, boolean uncached) {
  +      PropertiesCacheEntry prop = (PropertiesCacheEntry)cachedProperties.
  +          get(property);
  +
  +      if(prop != null) {
  +          if(!uncached)
  +              return prop.prop;
  +          else if(System.currentTimeMillis() - prop.time < 1000*60*5)
  +              return prop.prop;
  +      }
  +
  +      Vector list = new Vector(1);
  +
  +      list.add(property);
  +      fetchProperties(list, uncached);
  +
  +      /* Now it's definately cached (either as a value, or as null indicating
  +       * that it is absent, so look it up.
  +       */
  +      prop = (PropertiesCacheEntry)cachedProperties.get(property);
  +      if(prop != null)
  +          return prop.prop;
  +      else
  +          return null;
  +  }
  +
  +  public void fetchProperties(List properties) {
  +      fetchProperties(properties, false);
  +  }
  +
  +  public void fetchProperties(List properties, boolean uncached) {
  +      Vector propList = new Vector(properties.size());
  +
  +      Iterator i = properties.iterator();
  +
  +      while(i.hasNext()) {
  +          String propName = (String)i.next();
  +
  +          PropertiesCacheEntry prop = (PropertiesCacheEntry)cachedProperties.
  +              get(propName);
  +
  +          if(prop == null || (uncached && System.currentTimeMillis() - 
  +                      prop.time > 1000*60*5)) {
  +              propList.add(propName);
  +          }
  +      }
  +
  +      /* We didn't need to get anything! */
  +      if(propList.size() == 0) {
  +          return;
  +      }
  +
  +      /* These are very commonly requested soon after other properties - 
  +         as a simple optimisation, just request these along with others.
  +       */
  +      if(!propList.contains("current-user-privilege-set"))
  +          propList.add("current-user-privilege-set");
  +      if(!propList.contains("lockdiscovery"))
  +          propList.add("lockdiscovery");
  +
  +      SPPropFindMethod method = new SPPropFindMethod(getClient());
  +
  +      method.setPath(resourceUrlPath);
  +      method.setDepth(DepthSupport.DEPTH_0);
  +      try {
  +        method.executeByName(propList.elements());
  +        int status = method.getStatusCode();
  +
  +        if(status >= 200 && status < 300) {
  +            Enumeration props = propList.elements();
  +
  +            while(props.hasMoreElements()) {
  +                String propName = (String)props.nextElement();
  +                SPProperty spProp = (SPProperty)method.getProperty(propName);
  +
  +                if(spProp == null) {
  +                    cachedProperties.put(propName, 
  +                            new PropertiesCacheEntry(null));
  +                }
  +                else {
  +                    cachedProperties.put(propName, 
  +                            new PropertiesCacheEntry(spProp));
  +                }
  +            }
  +        }
  +        else if(status == 404) {
  +            Enumeration props = propList.elements();
  +            while(props.hasMoreElements()) {
  +                String propName = (String)props.nextElement();
  +                cachedProperties.put(propName, new PropertiesCacheEntry(null));
  +            }
  +        }
  +        else {
  +            showErrorMessage("Remote Failure",
  +                    "Unable to fetch properties on resource "
  +                    +resourceUrlPath+ "("+status+")");
  +        }
  +      } catch(Exception e) {
  +          e.printStackTrace();
  +      }
  +  }
  +
  +
  +  public void setProperties(Enumeration properties) {
  +      SPPropPatchMethod method = new SPPropPatchMethod(this);
  +
  +      while(properties.hasMoreElements()) {
  +          SPProperty prop = (SPProperty)properties.nextElement();
  +          method.addPropertyToSet(prop.getLocalName(), 
  +                  encodeXML(prop.getPropertyAsString()),
  +                  prop.getNamespace(), prop.getNamespaceURI());
  +
  +          cachedProperties.put(prop.getName(), 
  +                  new PropertiesCacheEntry(prop));
  +      }
  +
  +      try {
  +          method.execute();
  +          int status = method.getStatusCode();
  +
  +          if((status < 200 || status >= 300) && 
  +              status != HttpStatus.SC_NOT_FOUND) {
  +              showErrorMessage("Remote Failure", 
  +                      "Unable to set property on resource "+
  +                      getResourceUrlPath()+": "+status+".");
  +          }
  +      } catch(Exception e) {
  +          e.printStackTrace();
  +      }
     }
  +      
   
     public HttpClient getClient() {
       return client;
     }
   
  +  public String getCurrentLockToken() {
  +      return lockToken;
  +  }
  +
     public String getLockToken()  {
       String lockToken = null;
   
  @@ -180,52 +451,33 @@
           (LockdiscoveryProperty) getProperty("lockdiscovery");
   
       if (lockdiscoveryProp != null)  {
  -	String userName = getClient().getCredentials().getUserName();
  +	    String userName = getClient().getCredentials().getUserName();
           lockToken = lockdiscoveryProp.getLockToken(userName);
  +        this.lockToken = lockToken;
       }
   
       return lockToken;
     }
   
     public boolean hasReadAccess()  {
  -    if (! accessPrivilegeChecked)  {
  -        checkAccessPrivilege();
  -    }
  -    return readAccess;
  -  }
  +      CurrentUserPrivilegeSetProperty prop = (CurrentUserPrivilegeSetProperty)
  +          getProperty("current-user-privilege-set");
   
  -  public boolean hasWriteAccess()  {
  -    if (! accessPrivilegeChecked)  {
  -        checkAccessPrivilege();
  -    }
  -    return writeAccess;
  +      return (prop != null)?prop.hasReadAccess():true;
     }
   
  -  public boolean hasReadWriteAccess()  {
  -    if (! accessPrivilegeChecked)  {
  -        checkAccessPrivilege();
  -    }
  -    return readAccess && writeAccess;
  -  }
  +  public boolean hasWriteAccess()  {
  +      CurrentUserPrivilegeSetProperty prop = (CurrentUserPrivilegeSetProperty)
  +          getProperty("current-user-privilege-set");
   
  -  public void setPrivilege(boolean readAccess, boolean writeAccess)  {
  -    this.readAccess = readAccess;
  -    this.writeAccess = writeAccess;
  -    accessPrivilegeChecked = true;
  +      return (prop != null)?prop.hasWriteAccess():true;
     }
   
  +  public boolean hasReadWriteAccess()  {
  +      CurrentUserPrivilegeSetProperty prop = (CurrentUserPrivilegeSetProperty)
  +          getProperty("current-user-privilege-set");
   
  -  protected void checkAccessPrivilege()  {
  -    CurrentUserPrivilegeSetProperty userPrivilege =
  -	(CurrentUserPrivilegeSetProperty) SPUtils.getProperty(client,
  -	    resourceUrlPath, "current-user-privilege-set");
  -    if (userPrivilege != null)  {
  -        readAccess = userPrivilege.hasReadAccess();
  -        writeAccess = userPrivilege.hasWriteAccess();
  -        accessPrivilegeChecked = true;
  -    } else  {
  -        accessPrivilegeChecked = false;
  -    }
  +      return (prop != null)?(prop.hasWriteAccess()&&prop.hasReadAccess()):false;
     }
   
     public boolean equals(Object obj) {
  @@ -234,6 +486,60 @@
       return ( (client == objNode.getClient())
   	     && (resourceUrlPath.equals(objNode.getResourceUrlPath())) );
     }
  +
  +  protected class PropertiesCacheEntry {
  +
  +      public SPProperty prop;
  +      public long time;
  +      
  +      public PropertiesCacheEntry(SPProperty prop) {
  +          this.prop = prop;
  +          this.time = System.currentTimeMillis();
  +      }
  +  }
  +
  +  /* This is a nasty hack, should fix this properly one day */
  +  private String encodeXML(String in) {
  +      StringBuffer buf = new StringBuffer();
  +      int i;
  +
  +      char input[] = in.toCharArray();
  +
  +      for(i = 0; i < input.length; i++) {
  +          switch(input[i]) {
  +              case '&':
  +                  buf.append("&amp;");
  +                  break;
  +              case '>':
  +                  buf.append("&gt;");
  +                  break;
  +              case '<':
  +                  buf.append("&lt;");
  +                  break;
  +              default:
  +                  buf.append(input[i]);
  +                  break;
  +          }
  +      }
  +
  +      return buf.toString();
  +  }
  +
  +  protected static String getFileNameOfUrl(String path) {
  +      if(path.endsWith("/"))
  +          path = path.substring(0, path.length()-1);
  +      return path.substring(path.lastIndexOf("/") + 1);
  +  }
  +
  +  protected void showErrorMessage(String title, String message) 
  +      throws HttpException
  +  {
  +      JOptionPane.showMessageDialog(null, message, title, 
  +              JOptionPane.ERROR_MESSAGE);
  +
  +      throw new HttpException(message);
  +  }
  +
   
   } //End of SPResourceNode class
   
  
  
  
  1.5.2.1   +20 -31    jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java
  
  Index: SPWebFile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- SPWebFile.java	23 Oct 2001 23:39:34 -0000	1.5
  +++ SPWebFile.java	2 Mar 2002 17:38:36 -0000	1.5.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java,v 1.5 2001/10/23 23:39:34 msmith Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/10/23 23:39:34 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java,v 1.5.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.5.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -69,7 +69,6 @@
   import org.apache.webdav.lib.*;
   import org.apache.webdav.ui.lib.methods.*;
   import org.apache.webdav.lib.properties.*;
  -import org.apache.webdav.ui.util.SPUtils;
   
   import org.apache.commons.httpclient.HttpStatus;
   import org.apache.commons.httpclient.HttpClient;
  @@ -86,7 +85,7 @@
   public class SPWebFile extends SPResourceNode {
   
     public SPWebFile(HttpClient client, String urlPath)   {
  -    this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath));
  +    this(client, urlPath, getFileNameOfUrl(urlPath));
     }
   
     public SPWebFile(HttpClient client, String urlPath, String name)  {
  @@ -94,22 +93,7 @@
       this.resourceUrlPath = urlPath;
       this.name = name;
     }
  -/*
  -  public SPWebFile(HttpClient client, String urlPath, boolean readAccess,
  -            boolean writeAccess) {
  -    this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath), readAccess, writeAccess);
  -  }
   
  -  public SPWebFile(HttpClient client, String urlPath, String name,
  -            boolean readAccess, boolean writeAccess) {
  -    this.client = client;
  -    this.resourceUrlPath = urlPath;
  -    this.name = name;
  -    this.readAccess = readAccess;
  -    this.writeAccess = writeAccess;
  -    accessPrivilegeChecked = true;
  -  }
  -*/
     public List getChildren()  {
       return null;
     }
  @@ -121,7 +105,7 @@
     public boolean isAcceptable(String aFilterDescription) {
       boolean isAcceptable = false;
   
  -    String extension = SPUtils.getExtension(name);
  +    String extension = getExtension();
       int openingBrace = aFilterDescription.indexOf("(");
       int closingBrace = aFilterDescription.indexOf(")");
   
  @@ -163,7 +147,7 @@
         final String title = "Import Failure";
         final String msg = "Server Response Status is NOT OK ("+statusCode+")\n"+
         "Resource Path = "+resourceUrlPath;
  -      SPUtils.showMessageDialog(title, msg);
  +      showErrorMessage(title, msg);
       }
   
       return theString;
  @@ -194,7 +178,7 @@
         final String title = "Import Failure";
         final String msg = "Server Response Status is NOT OK ("+statusCode+")\n"+
         "Resource Path = "+resourceUrlPath;
  -      SPUtils.showMessageDialog(title, msg);
  +      showErrorMessage(title, msg);
         theStream = null;
       }
   
  @@ -207,7 +191,7 @@
           String title = "Export Failure";
           String msg = "Write Access Denied ("+HttpStatus.SC_FORBIDDEN+")\n"+
                 "Resource Path = "+resourceUrlPath;
  -        SPUtils.showMessageDialog(title, msg);
  +        showErrorMessage(title, msg);
           return (HttpStatus.SC_FORBIDDEN);
       }
   
  @@ -226,7 +210,7 @@
               msg = "Server Response Status is NOT OK ("+statusCode+")\n"+
                            "Resource Path = "+resourceUrlPath;
           }
  -        SPUtils.showMessageDialog(title, msg);
  +        showErrorMessage(title, msg);
       }
   
       return statusCode;
  @@ -238,7 +222,7 @@
           String title = "Export Failure";
           String msg = "Write Access Denied ("+HttpStatus.SC_FORBIDDEN+")\n"+
                 "Resource Path = "+resourceUrlPath;
  -        SPUtils.showMessageDialog(title, msg);
  +        showErrorMessage(title, msg);
           return (HttpStatus.SC_FORBIDDEN);
       }
   
  @@ -258,18 +242,23 @@
               msg = "Server Response Status is NOT OK ("+statusCode+")\n"
   		+"Resource Path = "+resourceUrlPath;
           }
  -        SPUtils.showMessageDialog(title, msg);
  +        showErrorMessage(title, msg);
       }
   
       return statusCode;
     }//putFileContent(File)
   
  -  public void setProperties(Enumeration properties) {
  -	SPUtils.setProperty(this, properties);
  -  }
  -
     public void refreshContent()  {
       //do nothing
  +  }
  +
  +  private String getExtension() {
  +      int i = getName().lastIndexOf(".");
  +
  +      if (i > 0 && i < getName().length() - 1)
  +          return getName().substring(i+1).toLowerCase();
  +      else
  +          return null;
     }
   
   } //End of SPWebFile class
  
  
  
  1.4.2.1   +39 -72    jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java
  
  Index: SPWebFolder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- SPWebFolder.java	16 Oct 2001 23:44:45 -0000	1.4
  +++ SPWebFolder.java	2 Mar 2002 17:38:36 -0000	1.4.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java,v 1.4 2001/10/16 23:44:45 msmith Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/10/16 23:44:45 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java,v 1.4.2.1 2002/03/02 17:38:36 cmlenz Exp $
  + * $Revision: 1.4.2.1 $
  + * $Date: 2002/03/02 17:38:36 $
    *
    * ====================================================================
    *
  @@ -67,9 +67,9 @@
   import java.io.*;
   
   import org.apache.webdav.lib.*;
  +import org.apache.webdav.lib.methods.DepthSupport;
   import org.apache.webdav.ui.lib.methods.SPPropFindMethod;
   import org.apache.webdav.ui.lib.properties.*;
  -import org.apache.webdav.ui.util.SPUtils;
   
   import org.apache.commons.httpclient.HttpStatus;
   import org.apache.commons.httpclient.HttpClient;
  @@ -90,7 +90,7 @@
     protected List children = null;
   
     public SPWebFolder(HttpClient client, String urlPath) {
  -    this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath));
  +    this(client, urlPath, getFileNameOfUrl(urlPath));
     }
   
     public SPWebFolder(HttpClient client, String urlPath, String name) {
  @@ -101,27 +101,6 @@
       this.resourceUrlPath = urlPath;
       this.name = name;
     }
  -/*
  -  public SPWebFolder(HttpClient client, String urlPath,
  -        boolean readAccess, boolean writeAccess) {
  -    this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath),
  -         readAccess, writeAccess);
  -  }
  -
  -  public SPWebFolder(HttpClient client, String urlPath, String name,
  -        boolean readAccess, boolean writeAccess) {
  -
  -    this.client = client;
  -
  -    //urlPath must point to a collection
  -    urlPath = (urlPath.endsWith("/")) ? urlPath : urlPath+"/";
  -    this.resourceUrlPath = urlPath;
  -    this.name = name;
  -    this.readAccess = readAccess;
  -    this.writeAccess = writeAccess;
  -    accessPrivilegeChecked = true;
  -  }
  -*/
   
     public List getChildren()  {
       if (children == null) {
  @@ -139,70 +118,58 @@
     }
   
     public void init() throws Exception  {
  +
       SPPropFindMethod propFindMethod = new SPPropFindMethod(client);
  +
       propFindMethod.setPath(resourceUrlPath);
  -    propFindMethod.execute();
  +
  +    Vector propList = new Vector(5);
  +    propList.add("current-user-privilege-set");
  +    propList.add("resourcetype");
  +    propList.add("lockdiscovery");
  +
  +    propFindMethod.setDepth(DepthSupport.DEPTH_1);
  +    propFindMethod.executeByName(propList.elements());
   
       int statusCode = propFindMethod.getStatusCode();
   
       if (statusCode<200 || statusCode >299)  {
         final String title = "Remote Failure";
         final String msg = "Unable to access a remote directory ("+statusCode+")";
  -      SPUtils.showMessageDialog(title, msg);
  +      showErrorMessage(title, msg);
       }
   
       children = new ArrayList();
       Enumeration enum = propFindMethod.getAllResponseURLs();
  +    // Ensure that we're not going to get caught out by an extra /
  +    String urlPathSlashIndep;
  +    if (resourceUrlPath.endsWith("/"))
  +        urlPathSlashIndep = resourceUrlPath.substring(0, resourceUrlPath.length()-1);
  +    else
  +        urlPathSlashIndep = resourceUrlPath + "/";
  +
   
       while (enum.hasMoreElements()){
         String url = (String) enum.nextElement();
  -      Property p = (Property)propFindMethod.getProperty("current-user-privilege-set", url);
  -	  //System.err.println("current-user-privilege-set is "+p.getClass().getName());
  -      CurrentUserPrivilegeSetProperty userPrivilege =
  -//	    (CurrentUserPrivilegeSetProperty)
  - //            propFindMethod.getProperty("current-user-privilege-set", url);
  -	(CurrentUserPrivilegeSetProperty)p;
  -
  -      boolean readAccess = userPrivilege.hasReadAccess();
  -      boolean writeAccess = userPrivilege.hasWriteAccess();
  -
  -      LockdiscoveryProperty lockdiscoveryProp =
  -	    (LockdiscoveryProperty)
  -	     propFindMethod.getProperty("lockdiscovery", url);
  -
  -      boolean readOnly=false;
  -      if (lockdiscoveryProp != null)  { //is being locked
  -	  String userName = client.getCredentials().getUserName();
  -	  if (lockdiscoveryProp.getLockToken(userName) == null)  {
  -	      // is locked by others
  -	      readOnly = true;
  -	  }
  -      }
   
  -      SPResourceNode newChild;
  +      if(!url.endsWith(resourceUrlPath) && !url.endsWith(urlPathSlashIndep)) {
  +          SPResourceNode newChild;
   
  -      // Pending: Waiting for the proper setting of "displayname" property
  -      // in the server
  +          if(propFindMethod.isCollection(url)) {
  +              newChild = new SPWebFolder(client, url);
  +          }
  +          else {
  +              newChild = new SPWebFile(client, url);
  +          }
  +          newChild.addCachedProperties(propFindMethod.getResponseProperties(
  +                      url), (Vector)propList.clone());
  +          children.add(newChild);
  +      }
  +      else {
  +          this.addCachedProperties(propFindMethod.getResponseProperties(
  +                      url), (Vector)propList.clone());
  +      }
   
  -      if( ! url.endsWith(resourceUrlPath) ) {
  -        //if not this SPWebFolder's url
  -        //create a SPWebFolder or SPWebFile child according to its type
  -
  -        if (propFindMethod.isCollection(url))  {
  -          newChild = new SPWebFolder(client, url);
  -        } else  {
  -          newChild = new SPWebFile(client, url);
  -        }
  -
  -	newChild.setPrivilege(readAccess, writeAccess);
  -	newChild.setReadOnlyCached(readOnly);
  -	newChild.setParent(this);
  -        children.add(newChild);
  -      } else  {
  -        this.readAccess = readAccess;
  -        this.writeAccess = writeAccess;
  -        accessPrivilegeChecked = true;
  -      }// if(! url.endsWidth...)
       }// while (enum...)
     }// init()
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +4 -4      jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lab/HostFrame.java
  
  Index: HostFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lab/HostFrame.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- HostFrame.java	17 Jul 2001 04:00:48 -0000	1.2
  +++ HostFrame.java	2 Mar 2002 17:38:37 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lab/HostFrame.java,v 1.2 2001/07/17 04:00:48 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:48 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lab/HostFrame.java,v 1.2.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -227,7 +227,7 @@
   	    this.currFile = aFile;
   	    // ...and mark the edit session as being clean
   	    this.dirty = false;
  -	    String mode = (aFile.isReadOnly()) ? "READ Only" : "READ/WRITE";
  +	    String mode = (aFile.isLockedByOthers()) ? "READ Only" : "READ/WRITE";
   	    statusTextLabel.setText("Opened "+aFile.getPath()+"  Mode: "+mode);
   
   	    statusCodeLabel.setText(""); //clear it
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +18 -28    jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java
  
  Index: SPLockMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SPLockMethod.java	17 Jul 2001 04:00:49 -0000	1.2
  +++ SPLockMethod.java	2 Mar 2002 17:38:37 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java,v 1.2 2001/07/17 04:00:49 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:49 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java,v 1.2.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -64,6 +64,7 @@
   package org.apache.webdav.ui.lib.methods;
   
   import java.util.Enumeration;
  +import java.io.IOException;
   
   import org.apache.webdav.lib.*;
   import org.apache.webdav.lib.methods.*;
  @@ -73,6 +74,7 @@
   
   import org.apache.commons.httpclient.HttpMethod;
   import org.apache.commons.httpclient.HttpClient;
  +import org.apache.commons.httpclient.HttpException;
   
   public class SPLockMethod extends LockMethod
         implements SPWebdavMethod {
  @@ -109,7 +111,7 @@
     public SPLockMethod(SPResourceNode resource,
                       String refreshOpaqueToken, long timeout) {
       super(resource.getResourceUrlPath(), refreshOpaqueToken, timeout);
  -    this.client = client;
  +    this.client = resource.getClient();
       setOwner(client.getCredentials().getUserName());
     }
   
  @@ -139,39 +141,27 @@
       }
     }
   
  -  public SPWebdavMethod execute() throws Exception {
  -    String lockToken = ((SPWebdavClient)client).getLockToken(path);
  -    SPLockMethod executedLockMethod = this;
  +  public SPWebdavMethod execute() throws IOException, HttpException {
       try {
  -      if (lockToken != null) {
  -        executedLockMethod = refresh(lockToken);
  -      } else  {
  -        client.executeMethod(this.getWebdavMethodHandle());
  -      }
  -    } catch(Exception e) {
  -      e.printStackTrace();
  -      throw e;
  +        client.executeMethod(this);
  +    } catch(IOException e) {
  +        e.printStackTrace();
  +        throw e;
  +    } catch(HttpException e) {
  +        e.printStackTrace();
  +        throw e;
       }
  -    return executedLockMethod;
  -  }//execute()
  -
  -  public HttpMethod getWebdavMethodHandle() {
       return this;
  -  }
  +  }//execute()
   
     public String toString()	{
       return (new String("LockMethod()"));
     }
   
  -  private SPLockMethod refresh(String lockToken) throws Exception {
  -    SPLockMethod lockMethod = new SPLockMethod(client, path, lockToken, getTimeout());
  -    try {
  -      client.executeMethod(lockMethod.getWebdavMethodHandle());
  -    } catch(Exception e)  {
  -      throw e;
  -    }
  -    return lockMethod;
  +  public HttpMethod getWebdavMethodHandle() {
  +    return this;
     }
  +
   
   }//End of SPLockMethod class
   
  
  
  
  1.3.2.1   +8 -6      jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java
  
  Index: SPPropFindMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- SPPropFindMethod.java	1 Aug 2001 03:42:59 -0000	1.3
  +++ SPPropFindMethod.java	2 Mar 2002 17:38:37 -0000	1.3.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java,v 1.3 2001/08/01 03:42:59 msmith Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/08/01 03:42:59 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java,v 1.3.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.3.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -144,6 +144,10 @@
   	if(propertyName.lastIndexOf(':') >= 0)
   		propertyName = propertyName.substring(propertyName.lastIndexOf(':')+1);
   
  +    // Seems to return null in this case
  +    if (urlPath.endsWith("/"))
  +        urlPath=urlPath.substring(0,urlPath.length()-1);
  +
       Enumeration propEnum = getResponseProperties(urlPath);
       boolean isFound = false;
   
  @@ -155,7 +159,6 @@
             isFound = true;
           }
       }// while (enum...)
  -
       return theProperty;
     }
   
  @@ -174,11 +177,11 @@
       }
     }
   
  +
     public SPWebdavMethod executeByName(Enumeration propertyList)
           throws Exception  {
       setPropertyNames(propertyList);
       setType(BY_NAME);
  -    setDepth(DepthSupport.DEPTH_0);
       return execute();
     }
   
  @@ -201,7 +204,6 @@
     public String toString()	{
       return (new String("PropFindMethod()"));
     }
  -
   }//End of SPPropFindMethod class
   
   
  
  
  
  1.2.2.1   +19 -3     jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropPatchMethod.java
  
  Index: SPPropPatchMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropPatchMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SPPropPatchMethod.java	17 Jul 2001 04:00:50 -0000	1.2
  +++ SPPropPatchMethod.java	2 Mar 2002 17:38:37 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropPatchMethod.java,v 1.2 2001/07/17 04:00:50 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:50 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropPatchMethod.java,v 1.2.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -70,11 +70,13 @@
   
   import org.apache.commons.httpclient.HttpMethod;
   import org.apache.commons.httpclient.HttpClient;
  +import org.apache.commons.httpclient.State;
   
   public class SPPropPatchMethod extends PropPatchMethod
         implements SPWebdavMethod {
   
     HttpClient client;
  +  String lockToken;
   
     public SPPropPatchMethod(HttpClient client)  {
       this.client = client;
  @@ -83,6 +85,7 @@
     public SPPropPatchMethod(SPResourceNode resource)  {
       this.client = resource.getClient();
       setPath(resource.getResourceUrlPath());
  +    lockToken = resource.getCurrentLockToken();
     }
   
     public void setClient(HttpClient client)  {
  @@ -118,6 +121,19 @@
   
     public String toString()	{
       return (new String("PropPatchMethod()"));
  +  }
  +
  +  /**
  +   * Generate additional headers needed by the request.
  +   * Overwrites this inherited function by adding If header
  +   *
  +   * @param host the host
  +   * @param state State token
  +   */
  +  public void generateHeaders(String host, State state) {
  +    super.generateHeaders(host, state);
  +    if(lockToken != null)
  +        setHeader("If", "(<" + lockToken + ">)");
     }
   
   } //End of SPPropPatchMethod class
  
  
  
  1.3.2.1   +11 -15    jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java
  
  Index: SPPutMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- SPPutMethod.java	10 Oct 2001 04:42:45 -0000	1.3
  +++ SPPutMethod.java	2 Mar 2002 17:38:37 -0000	1.3.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java,v 1.3 2001/10/10 04:42:45 msmith Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/10/10 04:42:45 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java,v 1.3.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.3.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,6 @@
   import org.apache.webdav.lib.*;
   import org.apache.webdav.lib.methods.*;
   import org.apache.webdav.ui.filechooser.dir.SPResourceNode;
  -import org.apache.webdav.ui.util.SPUtils;
   import org.apache.webdav.ui.SPWebdavClient;
   
   import org.apache.commons.httpclient.HttpMethod;
  @@ -79,7 +78,7 @@
         implements SPWebdavMethod {
   
     HttpClient client;
  -  private String lockToken=null;
  +  protected SPResourceNode resource = null;
   
     public SPPutMethod(HttpClient client)  {
       setClient(client);
  @@ -88,6 +87,7 @@
     public SPPutMethod(SPResourceNode resource) {
       setClient(resource.getClient());
       setPath(resource.getResourceUrlPath());
  +    this.resource = resource;
     }
   
     public void setClient(HttpClient client)  {
  @@ -107,14 +107,12 @@
     }
   
     public SPWebdavMethod execute() throws Exception {
  -    lockToken = ((SPWebdavClient)client).getLockToken(path); //the current token from the server
  -
       try {
         client.executeMethod(this.getWebdavMethodHandle());
  -      if (lockToken != null)  {
  -        SPUtils.lock(client, path); //by default, refresh the lock timeout
  -      }
  -
  +      if(resource != null && resource.getCurrentLockToken() != null)
  +          resource.lock();
  +      else
  +          System.err.println("ERROR: No resource available, cannot set locktoken");
       }
       catch(Exception e) {
         e.printStackTrace();
  @@ -136,10 +134,8 @@
      */
     public void generateHeaders(String host, State state) {
       super.generateHeaders(host, state);
  -    if(lockToken != null)
  -        setHeader("If", "(<" + lockToken + ">)");
  -    else
  -        System.err.println("ERROR: lockToken is null!");
  +    if(resource.getCurrentLockToken() != null)
  +        setHeader("If", "(<" + resource.getCurrentLockToken() + ">) ");
       setHeader("Content-Type", "text/xml");
     }
   
  
  
  
  1.2.2.1   +10 -13    jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java
  
  Index: SPUnlockMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- SPUnlockMethod.java	17 Jul 2001 04:00:50 -0000	1.2
  +++ SPUnlockMethod.java	2 Mar 2002 17:38:37 -0000	1.2.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java,v 1.2 2001/07/17 04:00:50 msmith Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/07/17 04:00:50 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java,v 1.2.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.2.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -66,7 +66,6 @@
   import org.apache.webdav.lib.*;
   import org.apache.webdav.lib.methods.*;
   import org.apache.webdav.ui.filechooser.dir.SPResourceNode;
  -import org.apache.webdav.ui.util.SPUtils;
   
   import org.apache.commons.httpclient.HttpMethod;
   import org.apache.commons.httpclient.HttpClient;
  @@ -85,6 +84,11 @@
       this.client = resource.getClient();
     }
   
  +  public SPUnlockMethod(SPResourceNode resource, String lockToken) {
  +      super(resource.getResourceUrlPath(), lockToken);
  +      this.client = resource.getClient();
  +  }
  +
     public void setClient(HttpClient client)  {
       this.client = client;
     }
  @@ -103,7 +107,6 @@
   
     public SPWebdavMethod execute() throws Exception {
       try {
  -      setLockToken();
         client.executeMethod(this.getWebdavMethodHandle());
       } catch(Exception e) {
         e.printStackTrace();
  @@ -112,20 +115,14 @@
       return this;
     }
   
  -  private void setLockToken() {
  -    SPResourceNode node = SPUtils.getSPResourceNode(client, path);
  -    if (node != null) {
  -      setLockToken(node.getLockToken());
  -    }
  +  public String toString()	{
  +    return (new String("UnlockMethod()"));
     }
   
     public HttpMethod getWebdavMethodHandle() {
       return this;
     }
   
  -  public String toString()	{
  -    return (new String("UnlockMethod()"));
  -  }
   
   }// End of SPUnlockMethod() class
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +5 -6      jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/LockdiscoveryProperty.java
  
  Index: LockdiscoveryProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/LockdiscoveryProperty.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- LockdiscoveryProperty.java	17 Jul 2001 04:00:53 -0000	1.1
  +++ LockdiscoveryProperty.java	2 Mar 2002 17:38:37 -0000	1.1.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/LockdiscoveryProperty.java,v 1.1 2001/07/17 04:00:53 msmith Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/07/17 04:00:53 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/LockdiscoveryProperty.java,v 1.1.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.1.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -114,13 +114,12 @@
       for (int i = 0; notFound && i < activeLockList.getLength(); i++ ) {
         Element activeLockElement = (Element) activeLockList.item(i);
         NodeList ownerList = activeLockElement.getElementsByTagName("owner");
  -
         if (ownerList.getLength() == 1) { //if exists
           Element ownerElement = (Element) ownerList.item(0);
   
           String activeLockOwner = DOMUtils.getTextValue(ownerElement);
  -
  -        notFound = (owner.indexOf(activeLockOwner)>=0) ? false : true;
  +        //notFound = (owner.indexOf(activeLockOwner)>=0) ? false : true;
  +        notFound = (activeLockOwner.indexOf(owner)>=0) ? false : true;
           theActiveLock = (notFound) ? null : activeLockElement;
   
         } //if (ownerList.getLength() == 1);
  
  
  
  1.1.2.1   +84 -12    jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java
  
  Index: SPProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- SPProperty.java	17 Jul 2001 04:00:53 -0000	1.1
  +++ SPProperty.java	2 Mar 2002 17:38:37 -0000	1.1.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java,v 1.1 2001/07/17 04:00:53 msmith Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/07/17 04:00:53 $
  + * $Header: /home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java,v 1.1.2.1 2002/03/02 17:38:37 cmlenz Exp $
  + * $Revision: 1.1.2.1 $
  + * $Date: 2002/03/02 17:38:37 $
    *
    * ====================================================================
    *
  @@ -71,7 +71,6 @@
   import org.w3c.dom.NodeList;
   
   import org.apache.webdav.lib.*;
  -import org.apache.webdav.ui.util.SPUtils;
   import org.apache.util.*;
   
   /**
  @@ -85,7 +84,15 @@
   
   public class SPProperty implements Property {
   
  -  Property property;
  +  Property property=null;
  +
  +  String name;
  +  String value;
  +  String localName;
  +  String namespaceURI;
  +  String namespace;
  +  Element element;
  +
   
     public static SPProperty factory(Property property) {
       SPProperty theSPProperty=null;
  @@ -95,7 +102,7 @@
         //It may or may not contain namespace. In addition, a property name
         //may have a dash character.
         //converToClassName() removes the namespace and any dash character
  -      String propName = SPUtils.convertToClassName(property.getName());
  +      String propName = convertToClassName(property.getLocalName());
   
         Class propClass = Class.forName(
   		  "org.apache.webdav.ui.lib.properties."+propName);
  @@ -110,28 +117,93 @@
       return theSPProperty;
     }
   
  -  protected SPProperty(Property property)  {
  +  /* There must be a more sensible way to do this... */
  +  public static String convertToClassName(String propertyName) {
  +      //Remove the namespace and any dash character out of propertyName
  +      //and change its first character to uppercase.
  +      String theResult="";
  +
  +      //First namespace
  +      int colonIndex = propertyName.indexOf(':');
  +      propertyName = (colonIndex >= 0)
  +                     ? propertyName.substring(colonIndex+1)
  +                     : propertyName;
  +
  +      propertyName = (propertyName.substring(0,1)).toUpperCase()+
  +                propertyName.substring(1)+"Property";
  +
  +      //Then dash character
  +      StringTokenizer stoken = new StringTokenizer(propertyName, "-");
  +      while (stoken.hasMoreTokens())  {
  +        String s = stoken.nextToken();
  +        theResult += (s.substring(0,1)).toUpperCase() + s.substring(1);
  +      }
  +      return theResult;
  +  }
  +
  +  public SPProperty() {
  +  }
  +
  +  public SPProperty(Property property)  {
       this.property = property;
     }
   
  +  public SPProperty(String namespace, String namespaceInfo, 
  +          String name, String value) 
  +  {
  +      this.namespace = namespace;
  +      this.namespaceURI = namespaceInfo;
  +      this.localName  = this.name = name;
  +      this.value = value;
  +  }
  +
  +  public SPProperty(String name, String value) 
  +  {
  +      this.namespaceURI = null;
  +      this.localName  = this.name = name;
  +      this.value = value;
  +  }
  +
     public String getName() {
  -    return property.getName();
  +      if(property != null)
  +          return property.getName();
  +      else
  +          return name;
     }
   
     public String getLocalName()  {
  -    return property.getLocalName();
  +      if(property != null)
  +          return property.getLocalName();
  +      else
  +          return localName;
  +  }
  +
  +  public String getNamespace() {
  +      if(property != null)
  +          return property.getNamespaceURI();
  +      else
  +          return namespace;
     }
   
     public String getNamespaceURI() {
  -    return property.getNamespaceURI();
  +      if(property != null)
  +          return property.getNamespaceURI();
  +      else
  +          return namespaceURI;
     }
   
     public Element getElement() {
  -    return property.getElement();
  +      if(property != null)
  +          return property.getElement();
  +      else
  +          return element;
     }
   
     public String getPropertyAsString() {
  -    return property.getPropertyAsString();
  +      if(property != null)
  +          return property.getPropertyAsString();
  +      else
  +          return value;
     }
   
     public int getStatusCode()  {
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>