remm        01/07/23 18:30:59

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        WebdavServlet.java
  Log:
  - Various fixes to support of lock-null properties. They are now included
    in a PROPFIND, and it's now possible to retrieve their (blank) properties.
  - Known issue : a lock-null property won't be removed when the associated
    lock expires.
  
  Revision  Changes    Path
  1.22      +61 -14    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java
  
  Index: WebdavServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- WebdavServlet.java        2001/07/23 06:27:40     1.21
  +++ WebdavServlet.java        2001/07/24 01:30:59     1.22
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v
 1.21 2001/07/23 06:27:40 remm Exp $
  - * $Revision: 1.21 $
  - * $Date: 2001/07/23 06:27:40 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v
 1.22 2001/07/24 01:30:59 remm Exp $
  + * $Revision: 1.22 $
  + * $Date: 2001/07/24 01:30:59 $
    *
    * ====================================================================
    *
  @@ -126,7 +126,7 @@
    * are handled by the DefaultServlet.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.21 $ $Date: 2001/07/23 06:27:40 $
  + * @version $Revision: 1.22 $ $Date: 2001/07/24 01:30:59 $
    */
   
   public class WebdavServlet
  @@ -402,6 +402,8 @@
           }
   
           String path = getRelativePath(req);
  +        if (path.endsWith("/"))
  +            path = path.substring(0, path.length() - 1);
   
           if ((path.toUpperCase().startsWith("/WEB-INF")) ||
               (path.toUpperCase().startsWith("/META-INF"))) {
  @@ -512,6 +514,39 @@
               object = resources.lookup(path);
           } catch (NamingException e) {
               exists = false;
  +            int slash = path.lastIndexOf('/');
  +            if (slash != -1) {
  +                String parentPath = path.substring(0, slash);
  +                Vector currentLockNullResources =
  +                    (Vector) lockNullResources.get(parentPath);
  +                if (currentLockNullResources != null) {
  +                    Enumeration lockNullResourcesList =
  +                        currentLockNullResources.elements();
  +                    while (lockNullResourcesList.hasMoreElements()) {
  +                        String lockNullPath = (String)
  +                            lockNullResourcesList.nextElement();
  +                        if (lockNullPath.equals(path)) {
  +                            resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
  +                            resp.setContentType("text/xml; charset=UTF-8");
  +                            // Create multistatus object
  +                            XMLWriter generatedXML = 
  +                                new XMLWriter(resp.getWriter());
  +                            generatedXML.writeXMLHeader();
  +                            generatedXML.writeElement
  +                                (null, "multistatus"
  +                                 + generateNamespaceDeclarations(),
  +                                 XMLWriter.OPENING);
  +                            parseLockNullProperties
  +                                (req, generatedXML, lockNullPath, type,
  +                                 properties);
  +                            generatedXML.writeElement(null, "multistatus",
  +                                                      XMLWriter.CLOSING);
  +                            generatedXML.sendData();
  +                            return;
  +                        }
  +                    }
  +                }
  +            }
           }
   
           if (!exists) {
  @@ -566,7 +601,6 @@
                               stackBelow.push(newPath);
                           }
                       } catch (NamingException e) {
  -                        e.printStackTrace();
                           resp.sendError
                               (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                path);
  @@ -576,8 +610,12 @@
                       if (depth > 0) {
                           // Displaying the lock-null resources present in that
                           // collection
  +                        String lockPath = currentPath;
  +                        if (lockPath.endsWith("/"))
  +                            lockPath = 
  +                                lockPath.substring(0, lockPath.length() - 1);
                           Vector currentLockNullResources =
  -                            (Vector) lockNullResources.get(currentPath);
  +                            (Vector) lockNullResources.get(lockPath);
                           if (currentLockNullResources != null) {
                               Enumeration lockNullResourcesList =
                                   currentLockNullResources.elements();
  @@ -585,7 +623,7 @@
                                   String lockNullPath = (String)
                                       lockNullResourcesList.nextElement();
                                   parseLockNullProperties
  -                                    (req, generatedXML, currentPath, type,
  +                                    (req, generatedXML, lockNullPath, type,
                                        properties);
                               }
                           }
  @@ -2243,10 +2281,15 @@
           if (!toAppend.startsWith("/"))
               toAppend = "/" + toAppend;
   
  -        generatedXML.writeText(rewriteUrl(absoluteUri + toAppend));
  +        generatedXML.writeText(rewriteUrl(normalize(absoluteUri + toAppend)));
   
           generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
   
  +        String resourceName = path;
  +        int lastSlash = path.lastIndexOf('/');
  +        if (lastSlash != -1)
  +            resourceName = resourceName.substring(lastSlash + 1);
  +
           switch (type) {
   
           case FIND_ALL_PROP :
  @@ -2257,9 +2300,11 @@
               generatedXML.writeProperty
                   (null, "creationdate",
                    getISOCreationDate(lock.creationDate.getTime()));
  -            generatedXML.writeProperty
  -                (null, "displayname",
  -                 rewriteUrl(path.replace('/', '_')));
  +            generatedXML.writeElement
  +                (null, "displayname", XMLWriter.OPENING);
  +            generatedXML.writeData(resourceName);
  +            generatedXML.writeElement
  +                (null, "displayname", XMLWriter.CLOSING);
               generatedXML.writeProperty(null, "getcontentlanguage",
                                          Locale.getDefault().toString());
               generatedXML.writeProperty(null, "getlastmodified",
  @@ -2353,9 +2398,11 @@
                           (null, "creationdate",
                            getISOCreationDate(lock.creationDate.getTime()));
                   } else if (property.equals("displayname")) {
  -                    generatedXML.writeProperty
  -                        (null, "displayname",
  -                         rewriteUrl(path.replace('/', '_')));
  +                    generatedXML.writeElement
  +                        (null, "displayname", XMLWriter.OPENING);
  +                    generatedXML.writeData(resourceName);
  +                    generatedXML.writeElement
  +                        (null, "displayname", XMLWriter.CLOSING);
                   } else if (property.equals("getcontentlanguage")) {
                       generatedXML.writeProperty
                           (null, "getcontentlanguage",
  
  
  

Reply via email to