dirkv       01/10/07 13:43:12

  Modified:    src/webdav/client/src/org/apache/webdav/cmd Slide.java
  Log:
  cleanup the commented log code and whitespace, no real changes
  
  Revision  Changes    Path
  1.41      +495 -522  
jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java
  
  Index: Slide.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- Slide.java        2001/08/26 18:30:53     1.40
  +++ Slide.java        2001/10/07 20:43:11     1.41
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.40 
2001/08/26 18:30:53 dirkv Exp $
  - * $Revision: 1.40 $
  - * $Date: 2001/08/26 18:30:53 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.41 
2001/10/07 20:43:11 dirkv Exp $
  + * $Revision: 1.41 $
  + * $Date: 2001/10/07 20:43:11 $
    *
    * ====================================================================
    *
  @@ -81,11 +81,7 @@
   
   import org.apache.commons.httpclient.HttpStatus;
   import org.apache.commons.httpclient.HttpException;
  -//import org.apache.commons.httpclient.log.Log;
  -//import org.apache.commons.httpclient.log.LogSource;
  -
   import org.apache.util.HttpURL;
  -
   import org.apache.webdav.lib.WebdavResource;
   import org.apache.webdav.lib.methods.*;
   import org.apache.webdav.lib.methods.DepthSupport;
  @@ -107,8 +103,6 @@
    */
   public class Slide {
   
  -    //static private final Log log = LogSource.getInstance(Slide.class.getName());
  -
       /**
        * The version information for the Slide client.
        */
  @@ -148,17 +142,8 @@
       /**
        * The debug level.
        */
  -    private int debugLevel = 0;//Log.WARN;
  +    private int debugLevel = 0;
   
  -    /**
  -     * Ste debug level
  -     */
  -/*
  -    private void setDebug(int level) {
  -        this.debugLevel=level;
  -        log.setLevel(debugLevel);
  -    }
  -*/
   
       /**
        * A space mark.
  @@ -202,7 +187,6 @@
                           break;
                       case 'd':
                           slide.debugLevel = Integer.MAX_VALUE;
  -                        //slide.setDebug(Log.DEBUG);
                           break;
                       default:
                           System.exit(-1);
  @@ -838,213 +822,213 @@
                       }
                   } else
                   if (todo.equalsIgnoreCase("grant")) {
  -                                 int count = params.size();
  -                                     String principal=null;
  -                                     String to=null;
  -                                     String path=null;
  -                                     String on=null;
  -                                     String permission=null;
  -                                     String namespace=null;
  -                                     if (count==3) { // grant <permission> to 
<principal>
  -                                             principal=(String)params.pop();
  -                                             to=(String)params.pop();
  -                                             
path=checkUri(webdavResource.getPath());
  -                                             on="on";
  -                                             permission=(String)params.pop();
  -                                             namespace=null;
  -                                     } else if (count==4) { // grant <namespace> 
<permission> to <principal>
  -                                             principal=(String)params.pop();
  -                                             to=(String)params.pop();
  -                                             
path=checkUri(webdavResource.getPath());
  -                                             on="on";
  -                                             permission=(String)params.pop();
  -                                             namespace=(String)params.pop();
  -                                     } else if (count==5) { // grant <permission> 
on <path> to <principal>
  -                                             principal=(String)params.pop();
  -                                             to=(String)params.pop();
  -                                             path=checkUri((String)params.pop());
  -                                             on=(String)params.pop();
  -                                             permission=(String)params.pop();
  -                                             namespace=null;
  -                                     } else if (count==6) { // grant <namespace> 
<permission> on <path> to <principal>
  -                                             principal=(String)params.pop();
  -                                             to=(String)params.pop();
  -                                             path=checkUri((String)params.pop());
  -                                             on=(String)params.pop();
  -                                             permission=(String)params.pop();
  -                                             namespace=(String)params.pop();
  -                                     } 
  -                                     if (!"to".equalsIgnoreCase(to) || 
!"on".equalsIgnoreCase(on)) {
  -                                             System.out.println("Syntax: grant 
<namespace> <permission> on <path> to <principal>");
  -                                             continue;
  -                                     }
  -                                     if (namespace==null) {
  -                                             namespace=resolveNamespace(permission);
  -                                             if (namespace==null) {
  -                                                     System.out.println("Could not 
resolve namespace for permission " + permission);
  -                                                     continue;
  -                                             }
  -                                     }
  -                                     
principal=checkPrincipal(principal,webdavResource,path);
  -                                     grant(webdavResource, namespace, permission, 
path, principal);
  +                    int count = params.size();
  +                    String principal=null;
  +                    String to=null;
  +                    String path=null;
  +                    String on=null;
  +                    String permission=null;
  +                    String namespace=null;
  +                    if (count==3) { // grant <permission> to <principal>
  +                        principal=(String)params.pop();
  +                        to=(String)params.pop();
  +                        path=checkUri(webdavResource.getPath());
  +                        on="on";
  +                        permission=(String)params.pop();
  +                        namespace=null;
  +                    } else if (count==4) { // grant <namespace> <permission> to 
<principal>
  +                        principal=(String)params.pop();
  +                        to=(String)params.pop();
  +                        path=checkUri(webdavResource.getPath());
  +                        on="on";
  +                        permission=(String)params.pop();
  +                        namespace=(String)params.pop();
  +                    } else if (count==5) { // grant <permission> on <path> to 
<principal>
  +                        principal=(String)params.pop();
  +                        to=(String)params.pop();
  +                        path=checkUri((String)params.pop());
  +                        on=(String)params.pop();
  +                        permission=(String)params.pop();
  +                        namespace=null;
  +                    } else if (count==6) { // grant <namespace> <permission> on 
<path> to <principal>
  +                        principal=(String)params.pop();
  +                         to=(String)params.pop();
  +                         path=checkUri((String)params.pop());
  +                         on=(String)params.pop();
  +                         permission=(String)params.pop();
  +                         namespace=(String)params.pop();
  +                     } 
  +                    if (!"to".equalsIgnoreCase(to) || !"on".equalsIgnoreCase(on)) {
  +                        System.out.println("Syntax: grant <namespace> <permission> 
on <path> to <principal>");
  +                        continue;
  +                    }
  +                    if (namespace==null) {
  +                        namespace=resolveNamespace(permission);
  +                        if (namespace==null) {
  +                            System.out.println("Could not resolve namespace for 
permission " + permission);
  +                            continue;
  +                        }
  +                    }
  +                    principal=checkPrincipal(principal,webdavResource,path);
  +                    grant(webdavResource, namespace, permission, path, principal);
                   } else
                   if (todo.equalsIgnoreCase("deny")) {
                       int count = params.size();
  -                     String principal=null;
  -                     String to=null;
  -                     String path=null;
  -                     String on=null;
  -                     String permission=null;
  -                     String namespace=null;
  -                     if (count==3) { // deny <permission> to <principal>
  -                             principal=(String)params.pop();
  -                             to=(String)params.pop();
  -                             path=checkUri(webdavResource.getPath());
  -                             on="on";
  -                             permission=(String)params.pop();
  -                             namespace=null;
  -                     } else if (count==4) { // deny <namespace> <permission> to 
<principal>
  -                             principal=(String)params.pop();
  -                             to=(String)params.pop();
  -                             path=checkUri(webdavResource.getPath());
  -                             on="on";
  -                             permission=(String)params.pop();
  -                             namespace=(String)params.pop();
  -                     } else if (count==5) { // deny <permission> on <path> to 
<principal>
  -                             principal=(String)params.pop();
  -                             to=(String)params.pop();
  -                             path=checkUri((String)params.pop());
  -                             on=(String)params.pop();
  -                             permission=(String)params.pop();
  -                             namespace=null;
  -                     } else if (count==6) { // deny <namespace> <permission> on 
<path> to <principal>
  -                             principal=(String)params.pop();
  -                             to=(String)params.pop();
  -                             path=checkUri((String)params.pop());
  -                             on=(String)params.pop();
  -                             permission=(String)params.pop();
  -                             namespace=(String)params.pop();
  -                     } 
  -                     if (!"to".equalsIgnoreCase(to) || !"on".equalsIgnoreCase(on)) {
  -                             System.out.println("Syntax: deny <namespace> 
<permission> on <path> to <principal>");
  -                             continue;
  -                     }
  -                     if (namespace==null) {
  -                             namespace=resolveNamespace(permission);
  -                             if (namespace==null) {
  -                                     System.out.println("Could not resolve 
namespace for permission " + permission);
  -                                     continue;
  -                             }
  -                     }
  -                     principal=checkPrincipal(principal,webdavResource,path);
  -                     deny(webdavResource, namespace, permission, path, principal);
  +                    String principal=null;
  +                    String to=null;
  +                    String path=null;
  +                    String on=null;
  +                    String permission=null;
  +                    String namespace=null;
  +                    if (count==3) { // deny <permission> to <principal>
  +                        principal=(String)params.pop();
  +                        to=(String)params.pop();
  +                        path=checkUri(webdavResource.getPath());
  +                        on="on";
  +                        permission=(String)params.pop();
  +                        namespace=null;
  +                    } else if (count==4) { // deny <namespace> <permission> to 
<principal>
  +                        principal=(String)params.pop();
  +                        to=(String)params.pop();
  +                        path=checkUri(webdavResource.getPath());
  +                        on="on";
  +                        permission=(String)params.pop();
  +                        namespace=(String)params.pop();
  +                    } else if (count==5) { // deny <permission> on <path> to 
<principal>
  +                        principal=(String)params.pop();
  +                        to=(String)params.pop();
  +                        path=checkUri((String)params.pop());
  +                        on=(String)params.pop();
  +                        permission=(String)params.pop();
  +                        namespace=null;
  +                    } else if (count==6) { // deny <namespace> <permission> on 
<path> to <principal>
  +                        principal=(String)params.pop();
  +                        to=(String)params.pop();
  +                        path=checkUri((String)params.pop());
  +                        on=(String)params.pop();
  +                        permission=(String)params.pop();
  +                        namespace=(String)params.pop();
  +                    } 
  +                    if (!"to".equalsIgnoreCase(to) || !"on".equalsIgnoreCase(on)) {
  +                        System.out.println("Syntax: deny <namespace> <permission> 
on <path> to <principal>");
  +                        continue;
  +                    }
  +                    if (namespace==null) {
  +                        namespace=resolveNamespace(permission);
  +                        if (namespace==null) {
  +                            System.out.println("Could not resolve namespace for 
permission " + permission);
  +                            continue;
  +                        }
  +                    }
  +                    principal=checkPrincipal(principal,webdavResource,path);
  +                    deny(webdavResource, namespace, permission, path, principal);
                   } else
                   if (todo.equalsIgnoreCase("revoke")) {
                       int count = params.size();
  -                     String principal=null;
  -                     String from=null;
  -                     String path=null;
  -                     String on=null;
  -                     String permission=null;
  -                     String namespace=null;
  -                     if (count==3) { // revoke <permission> to <principal>
  -                             principal=(String)params.pop();
  -                             from=(String)params.pop();
  -                             path=checkUri(webdavResource.getPath());
  -                             on="on";
  -                             permission=(String)params.pop();
  -                             namespace=null;
  -                     } else if (count==4) { // revoke <namespace> <permission> from 
<principal>
  -                             principal=(String)params.pop();
  -                             from=(String)params.pop();
  -                             path=checkUri(webdavResource.getPath());
  -                             on="on";
  -                             permission=(String)params.pop();
  -                             namespace=(String)params.pop();
  -                     } else if (count==5) { // revoke <permission> on <path> from 
<principal>
  -                             principal=(String)params.pop();
  -                             from=(String)params.pop();
  -                             path=checkUri((String)params.pop());
  -                             on=(String)params.pop();
  -                             permission=(String)params.pop();
  -                             namespace=null;
  -                     } else if (count==6) { // revoke <namespace> <permission> on 
<path> from <principal>
  -                             principal=(String)params.pop();
  -                             from=(String)params.pop();
  -                             path=checkUri((String)params.pop());
  -                             on=(String)params.pop();
  -                             permission=(String)params.pop();
  -                             namespace=(String)params.pop();
  -                     } 
  -                     if (!"from".equalsIgnoreCase(from) || 
!"on".equalsIgnoreCase(on)) {
  -                             System.out.println("Syntax: revoke <namespace> 
<permission> on <path> from <principal>");
  -                             continue;
  -                     }
  -                     if (namespace==null) {
  -                             namespace=resolveNamespace(permission);
  -                             if (namespace==null) {
  -                                     System.out.println("Could not resolve 
namespace for permission " + permission);
  -                                     continue;
  -                             }
  -                     }
  -                     principal=checkPrincipal(principal,webdavResource,path);
  -                     revoke(webdavResource, namespace, permission, path, principal);
  +                    String principal=null;
  +                    String from=null;
  +                    String path=null;
  +                    String on=null;
  +                    String permission=null;
  +                    String namespace=null;
  +                    if (count==3) { // revoke <permission> to <principal>
  +                        principal=(String)params.pop();
  +                        from=(String)params.pop();
  +                        path=checkUri(webdavResource.getPath());
  +                        on="on";
  +                        permission=(String)params.pop();
  +                        namespace=null;
  +                    } else if (count==4) { // revoke <namespace> <permission> from 
<principal>
  +                        principal=(String)params.pop();
  +                        from=(String)params.pop();
  +                        path=checkUri(webdavResource.getPath());
  +                        on="on";
  +                        permission=(String)params.pop();
  +                        namespace=(String)params.pop();
  +                    } else if (count==5) { // revoke <permission> on <path> from 
<principal>
  +                        principal=(String)params.pop();
  +                        from=(String)params.pop();
  +                        path=checkUri((String)params.pop());
  +                        on=(String)params.pop();
  +                        permission=(String)params.pop();
  +                        namespace=null;
  +                    } else if (count==6) { // revoke <namespace> <permission> on 
<path> from <principal>
  +                        principal=(String)params.pop();
  +                        from=(String)params.pop();
  +                        path=checkUri((String)params.pop());
  +                        on=(String)params.pop();
  +                        permission=(String)params.pop();
  +                        namespace=(String)params.pop();
  +                    } 
  +                    if (!"from".equalsIgnoreCase(from) || 
!"on".equalsIgnoreCase(on)) {
  +                        System.out.println("Syntax: revoke <namespace> <permission> 
on <path> from <principal>");
  +                        continue;
  +                    }
  +                    if (namespace==null) {
  +                        namespace=resolveNamespace(permission);
  +                        if (namespace==null) {
  +                            System.out.println("Could not resolve namespace for 
permission " + permission);
  +                            continue;
  +                        }
  +                    }
  +                    principal=checkPrincipal(principal,webdavResource,path);
  +                    revoke(webdavResource, namespace, permission, path, principal);
                   } else
                   if (todo.equalsIgnoreCase("acl")) {
  -                                 String path=null;
  -                                     AclProperty acl=null;
  +                    String path=null;
  +                    AclProperty acl=null;
                       int count = params.size();
                       if (count>1) {
                           System.out.println("acl has a maximum of 1 argument");
                           continue;
  +                    }
  +                    if (count==1) {
  +                        path=checkUri((String)params.pop());
  +                    }
  +                    else {
  +                        path=webdavResource.getPath();
                       }
  -                                     if (count==1) {
  -                                             path=checkUri((String)params.pop());
  -                                     }
  -                                     else {
  -                                             path=webdavResource.getPath();
  -                                     }
  -                                     acl = webdavResource.aclfindMethod(path);
  -
  -                                     if (acl==null)
  -                                     {
  -                                         System.out.println("Error: PropFind didn't 
return an AclProperty!");
  +                    acl = webdavResource.aclfindMethod(path);
  +
  +                    if (acl==null)
  +                    {
  +                        System.out.println("Error: PropFind didn't return an 
AclProperty!");
                           continue;
  -                                     }
  -                                     System.out.println();
  -                                     showAces(path, acl.getAces());
  +                    }
  +                    System.out.println();
  +                    showAces(path, acl.getAces());
                   } else
                   if (todo.equalsIgnoreCase("principalcol") || 
  -                                 todo.equalsIgnoreCase("principalcoll") ||
  -                                 todo.equalsIgnoreCase("principalcollection") ||
  -                                 todo.equalsIgnoreCase("principalcollectionset") ||
  -                                 todo.equalsIgnoreCase("principal-collection-set")) 
{
  +                    todo.equalsIgnoreCase("principalcoll") ||
  +                    todo.equalsIgnoreCase("principalcollection") ||
  +                    todo.equalsIgnoreCase("principalcollectionset") ||
  +                    todo.equalsIgnoreCase("principal-collection-set")) {
                       String path=null;
  -                     PrincipalCollectionSetProperty set=null;
  +                    PrincipalCollectionSetProperty set=null;
                       int count = params.size();
                       if (count>1) {
                           System.out.println("principalcol has a maximum of 1 
argument");
                           continue;
  +                    }
  +                    if (count==1) {
  +                        path=checkUri((String)params.pop());
                       }
  -                     if (count==1) {
  -                             path=checkUri((String)params.pop());
  -                     }
  -                     else {
  -                             path=webdavResource.getPath();
  -                     }
  -                     set = webdavResource.principalCollectionSetFindMethod(path);
  -
  -                     if (set==null)
  -                     {
  -                         System.out.println("Error: PropFind didn't return an 
PrincipalCollectionSetProperty!");
  +                    else {
  +                        path=webdavResource.getPath();
  +                    }
  +                    set = webdavResource.principalCollectionSetFindMethod(path);
  +
  +                    if (set==null)
  +                    {
  +                        System.out.println("Error: PropFind didn't return an 
PrincipalCollectionSetProperty!");
                           continue;
  -                     }
  -                     System.out.println();
  -                                     System.out.println("PrincipalCollectionSet for 
" + path + ":");
  -                                     String[] hrefs=set.getHrefs();
  -                                     for (int i=0 ; i<hrefs.length ; i++)
  -                                             System.out.println("   " + hrefs[i]);
  -                                     System.out.println();   
  +                    }
  +                    System.out.println();
  +                    System.out.println("PrincipalCollectionSet for " + path + ":");
  +                    String[] hrefs=set.getHrefs();
  +                    for (int i=0 ; i<hrefs.length ; i++)
  +                        System.out.println("   " + hrefs[i]);
  +                    System.out.println();    
                   } else
                   if (todo.equalsIgnoreCase("propget") ||
                       todo.equalsIgnoreCase("propfind")) {
  @@ -1057,7 +1041,7 @@
   
                       Vector properties = new Vector();
                       for (int i = 0; i < count-1; i++) {
  -                                             PropertyName property = new 
PropertyName("DAV:", (String) params.pop());
  +                        PropertyName property = new PropertyName("DAV:", (String) 
params.pop());
                           properties.addElement(property);
                       }
                       String path = checkUri((String) params.pop());
  @@ -1299,26 +1283,26 @@
                       }
                   } else
                   if (todo.equalsIgnoreCase("locks")) {
  -                                     String path=null;
  -                                     int count = params.size();
  -                                     if (count>1) {
  -                                         System.out.println("locks has a maximum of 
1 argument");
  -                                         continue;
  -                                     }
  -                                     if (count==1) {
  -                                             path=checkUri((String)params.pop());
  -                                     }
  -                                     else {
  -                                             path=webdavResource.getPath();
  -                                     }
  -                                     LockDiscoveryProperty 
lockDiscoveryProperty=webdavResource.lockDiscoveryPropertyFindMethod(path);
  -                                     if (lockDiscoveryProperty==null) {
  -                                             System.out.println("Server did not 
return a LockDiscoveryProperty.");
  -                                             
System.err.println(webdavResource.getStatusMessage());
  -                                             continue;
  -                                     }
  -                                     Lock[] 
locks=lockDiscoveryProperty.getActiveLocks();
  -                                     showLocks(path,locks);
  +                    String path=null;
  +                    int count = params.size();
  +                    if (count>1) {
  +                        System.out.println("locks has a maximum of 1 argument");
  +                        continue;
  +                    }
  +                    if (count==1) {
  +                        path=checkUri((String)params.pop());
  +                    }
  +                    else {
  +                        path=webdavResource.getPath();
  +                    }
  +                    LockDiscoveryProperty 
lockDiscoveryProperty=webdavResource.lockDiscoveryPropertyFindMethod(path);
  +                    if (lockDiscoveryProperty==null) {
  +                        System.out.println("Server did not return a 
LockDiscoveryProperty.");
  +                        System.err.println(webdavResource.getStatusMessage());
  +                        continue;
  +                    }
  +                    Lock[] locks=lockDiscoveryProperty.getActiveLocks();
  +                    showLocks(path,locks);
                   } else
                   if (todo.equalsIgnoreCase("lock")) {
                       if (params.size() == 1) {
  @@ -1338,10 +1322,10 @@
                               System.err.println("Error: Check! " +
                                   e.getMessage());
                           }
  +                    }
  +                    else {
  +                        System.out.println("Syntax: lock <path>");
                       }
  -                                     else {
  -                                             System.out.println("Syntax: lock 
<path>");
  -                                     }
                   } else
                   if (todo.equalsIgnoreCase("unlock")) {
                       if (params.size() == 1) {
  @@ -1362,9 +1346,9 @@
                                   e.getMessage());
                           }
                       }
  -                     else {
  -                             System.out.println("Syntax: unlock <path>");
  -                     }
  +                    else {
  +                        System.out.println("Syntax: unlock <path>");
  +                    }
                   } else
                   if (todo.equalsIgnoreCase("set")) {
                       if (params.size() == 2) {
  @@ -1383,12 +1367,10 @@
                           } else if (key.equalsIgnoreCase("debug")) {
                               if (value.equalsIgnoreCase("on")) {
                                   debugLevel = Integer.MAX_VALUE;
  -                                //setDebug(Log.DEBUG);
                                   webdavResource.setDebug(debugLevel);
                                   System.out.println("The debug flag is on.");
                               } else if (value.equalsIgnoreCase("off")) {
                                   debugLevel = 0;
  -                                //setDebug(Log.WARN);
                                   webdavResource.setDebug(debugLevel);
                                   System.out.println("The debug flag is off.");
                               } else {
  @@ -1432,25 +1414,25 @@
           return normalize(uri);
       }
   
  -     private String checkPrincipal(String principal, WebdavResource webdavResource, 
String path) throws HttpException,IOException
  -     {
  -             // Do not complete reserved words       
  +    private String checkPrincipal(String principal, WebdavResource webdavResource, 
String path) throws HttpException,IOException
  +    {
  +        // Do not complete reserved words    
           String[] types={"all","authenticated","unauthenticated","property","self"};
  -             for (int i=0; i<types.length ; i++)
  -             {
  -                     if (types[i].equals(principal))
  -                             return principal;
  -             }
  -     
  -             // FIXME: when search support is complete enhance this
  -             //        to really search for the principal
  -             if (!principal.startsWith("/") && !principal.startsWith("http")) {
  -                     PrincipalCollectionSetProperty set = 
webdavResource.principalCollectionSetFindMethod(path);
  -                     if ((set!=null) && (set.getHrefs().length==1))
  -                             principal = set.getHrefs()[0] + "/" + principal;
  -             }
  -             return normalize(principal);
  -     }
  +        for (int i=0; i<types.length ; i++)
  +        {
  +            if (types[i].equals(principal))
  +                return principal;
  +        }
  +    
  +        // FIXME: when search support is complete enhance this
  +        //        to really search for the principal
  +        if (!principal.startsWith("/") && !principal.startsWith("http")) {
  +            PrincipalCollectionSetProperty set = 
webdavResource.principalCollectionSetFindMethod(path);
  +            if ((set!=null) && (set.getHrefs().length==1))
  +                principal = set.getHrefs()[0] + "/" + principal;
  +        }
  +        return normalize(principal);
  +    }
   
       /**
        * Set the path.
  @@ -1669,282 +1651,273 @@
           } catch( InterruptedException ex ) {
           }
       }
  +
  +    private String resolveNamespace(String permission)
  +    {
  +        String DEFAULT_NAMESPACE = "DAV:";
  +        String SLIDE_NAMESPACE = "http://jakarta.apache.org/slide/";;
  +        String namespace=null;
   
  -     private String resolveNamespace(String permission)
  -     {
  -             String DEFAULT_NAMESPACE = "DAV:";
  -             String SLIDE_NAMESPACE = "http://jakarta.apache.org/slide/";;
  -             String namespace=null;
  -
  -             if (permission==null)
  -                     return null;
  -             
  -             if ((permission.equalsIgnoreCase("all")) ||
  -                 (permission.equalsIgnoreCase("read")) ||
  -                 (permission.equalsIgnoreCase("write")) ||
  -                 (permission.equalsIgnoreCase("read-acl")) ||
  -                 (permission.equalsIgnoreCase("write-acl")))
  -         {
  -                 namespace=DEFAULT_NAMESPACE;
  -             }
  -             
  -             if ((permission.equalsIgnoreCase("read-object")) ||
  -                 (permission.equalsIgnoreCase("read-revision-metadata")) ||
  -                 (permission.equalsIgnoreCase("read-revision-content")) ||
  -                 (permission.equalsIgnoreCase("create-object")) ||
  -                 (permission.equalsIgnoreCase("remove-object")) ||
  -                 (permission.equalsIgnoreCase("lock-object")) ||
  -                 (permission.equalsIgnoreCase("read-locks")) ||
  -                 (permission.equalsIgnoreCase("create-revision-metadata")) ||
  -                 (permission.equalsIgnoreCase("modify-revision-metadata")) ||
  -                 (permission.equalsIgnoreCase("remove-revision-metadata")) ||
  -                 (permission.equalsIgnoreCase("create-revision-content")) ||
  -                 (permission.equalsIgnoreCase("modify-revision-content")) ||
  -                 (permission.equalsIgnoreCase("remove-revision-content")) ||
  -                 (permission.equalsIgnoreCase("grant-permission")) ||
  -                 (permission.equalsIgnoreCase("revoke-permission")))
  -             {
  -                     namespace=SLIDE_NAMESPACE;
  -             }
  -             
  -             return namespace;
  -     }
  -
  -     private boolean grant(WebdavResource webdavResource, String namespace, String 
permission, String path, String principal) throws HttpException, IOException
  -     {
  -             System.out.println("grant " + namespace + permission + " on " + path + 
" to " + principal);
  -             return addPermission(webdavResource, namespace, permission, path, 
principal, false);
  -     }
  -
  -     private boolean deny(WebdavResource webdavResource, String namespace, String 
permission, String path, String principal) throws HttpException, IOException
  -     {
  -             System.out.println("deny " + namespace + permission + " on " + path + 
" to " + principal);
  -             return addPermission(webdavResource, namespace, permission, path, 
principal, true);
  -     }
  -
  -     private boolean revoke(WebdavResource webdavResource, String namespace, String 
permission, String path, String principal) throws HttpException, IOException
  -     {
  -             System.out.println("revoke " + namespace + permission + " on " + path 
+ " from " + principal);
  -             return removePermission(webdavResource, namespace, permission, path, 
principal);
  -     }
  -
  -     private boolean addPermission(WebdavResource webdavResource, String namespace, 
String permission, String path, String principal, boolean negative) throws 
HttpException, IOException
  -     {
  -
  -             AclProperty acl = webdavResource.aclfindMethod(path);
  -             if (acl==null)
  -             {
  -                     System.out.println("Error: PropFind didn't return an 
AclProperty!");
  -                     return false;
  -             }
  -             Ace[] aces=acl.getAces();
  +        if (permission==null)
  +            return null;
  +        
  +        if ((permission.equalsIgnoreCase("all")) ||
  +            (permission.equalsIgnoreCase("read")) ||
  +            (permission.equalsIgnoreCase("write")) ||
  +            (permission.equalsIgnoreCase("read-acl")) ||
  +            (permission.equalsIgnoreCase("write-acl")))
  +        {
  +            namespace=DEFAULT_NAMESPACE;
  +        }
  +        
  +        if ((permission.equalsIgnoreCase("read-object")) ||
  +            (permission.equalsIgnoreCase("read-revision-metadata")) ||
  +            (permission.equalsIgnoreCase("read-revision-content")) ||
  +            (permission.equalsIgnoreCase("create-object")) ||
  +            (permission.equalsIgnoreCase("remove-object")) ||
  +            (permission.equalsIgnoreCase("lock-object")) ||
  +            (permission.equalsIgnoreCase("read-locks")) ||
  +            (permission.equalsIgnoreCase("create-revision-metadata")) ||
  +            (permission.equalsIgnoreCase("modify-revision-metadata")) ||
  +            (permission.equalsIgnoreCase("remove-revision-metadata")) ||
  +            (permission.equalsIgnoreCase("create-revision-content")) ||
  +            (permission.equalsIgnoreCase("modify-revision-content")) ||
  +            (permission.equalsIgnoreCase("remove-revision-content")) ||
  +            (permission.equalsIgnoreCase("grant-permission")) ||
  +            (permission.equalsIgnoreCase("revoke-permission")))
  +        {
  +            namespace=SLIDE_NAMESPACE;
  +        }
  +        
  +        return namespace;
  +    }
  +
  +    private boolean grant(WebdavResource webdavResource, String namespace, String 
permission, String path, String principal) throws HttpException, IOException
  +    {
  +        System.out.println("grant " + namespace + permission + " on " + path + " to 
" + principal);
  +        return addPermission(webdavResource, namespace, permission, path, 
principal, false);
  +    }
  +
  +    private boolean deny(WebdavResource webdavResource, String namespace, String 
permission, String path, String principal) throws HttpException, IOException
  +    {
  +        System.out.println("deny " + namespace + permission + " on " + path + " to 
" + principal);
  +        return addPermission(webdavResource, namespace, permission, path, 
principal, true);
  +    }
  +
  +    private boolean revoke(WebdavResource webdavResource, String namespace, String 
permission, String path, String principal) throws HttpException, IOException
  +    {
  +        System.out.println("revoke " + namespace + permission + " on " + path + " 
from " + principal);
  +        return removePermission(webdavResource, namespace, permission, path, 
principal);
  +    }
  +
  +    private boolean addPermission(WebdavResource webdavResource, String namespace, 
String permission, String path, String principal, boolean negative) throws 
HttpException, IOException
  +    {
  +
  +        AclProperty acl = webdavResource.aclfindMethod(path);
  +        if (acl==null)
  +        {
  +            System.out.println("Error: PropFind didn't return an AclProperty!");
  +            return false;
  +        }
  +        Ace[] aces=acl.getAces();
                   
  -                if (debugLevel>5) {
  -                    //if (log.isDebugEnabled()) {
  -                    System.out.println();
  -                    System.out.println("ACL from server");
  -                 showAces(path, aces);
  -             }
  -             
  -             Ace ace=null;
  -             for (int i=0; i<aces.length && (ace==null); i++)
  -             {
  -                     if ((aces[i].isNegative()==negative) && !aces[i].isProtected() 
  -                         && !aces[i].isInherited() && 
aces[i].getPrincipal().equals(principal))
  -                     {
  -                             if (debugLevel>5)
  -                                    //if (log.isDebugEnabled())
  -                                    System.out.println("found ace");
  -                             ace=aces[i];
  -                     }
  -             }
  -             if (ace==null)
  -             {
  -                     Ace[] oldAces=aces;
  -                     aces=new Ace[oldAces.length+1];
  -                     System.arraycopy(oldAces,0,aces,0,oldAces.length);
  -                     ace=new Ace(principal, negative, false, false,null);
  -                     aces[oldAces.length]=ace;
  -             }
  -             
  -             Privilege privilege=new Privilege(namespace, permission, null);
  -             ace.addPrivilege(privilege);
  -             
  -             if (debugLevel>5) {
  -                    //if (log.isDebugEnabled()) {
  -                    System.out.println();
  -                    System.out.println("ACL with updated privileges");
  -                 showAces(path, aces);
  -             }
  -
  -             boolean success = webdavResource.aclMethod(path,aces);
  -     
  -             if (!success)
  -            System.err.println(webdavResource.getStatusMessage());   
  +        if (debugLevel>5) {
  +            System.out.println();
  +            System.out.println("ACL from server");
  +            showAces(path, aces);
  +        }
  +        
  +        Ace ace=null;
  +        for (int i=0; i<aces.length && (ace==null); i++)
  +        {
  +            if ((aces[i].isNegative()==negative) && !aces[i].isProtected() 
  +                && !aces[i].isInherited() && 
aces[i].getPrincipal().equals(principal))
  +            {
  +                if (debugLevel>5)
  +                    System.out.println("found ace");
  +                ace=aces[i];
  +            }
  +        }
  +        if (ace==null)
  +        {
  +            Ace[] oldAces=aces;
  +            aces=new Ace[oldAces.length+1];
  +            System.arraycopy(oldAces,0,aces,0,oldAces.length);
  +            ace=new Ace(principal, negative, false, false,null);
  +            aces[oldAces.length]=ace;
  +        }
  +        
  +        Privilege privilege=new Privilege(namespace, permission, null);
  +        ace.addPrivilege(privilege);
  +        
  +        if (debugLevel>5) {
  +            System.out.println();
  +            System.out.println("ACL with updated privileges");
  +            showAces(path, aces);
  +        }
  +
  +        boolean success = webdavResource.aclMethod(path,aces);
  +    
  +        if (!success)
  +            System.err.println(webdavResource.getStatusMessage());    
  +
  +        if (debugLevel>5) {
  +            acl = webdavResource.aclfindMethod(path);
  +            if (acl==null)
  +                System.out.println("Error: PropFind didn't return an AclProperty!");
  +            else 
  +            {    
  +                aces=acl.getAces();
  +                System.out.println();
  +                System.out.println("ACL from server after update");
  +                showAces(path, aces);
  +            }
  +        }
  +            
  +        return success;
  +    }
  +
  +    private boolean removePermission(WebdavResource webdavResource, String 
namespace, String permission, String path, String principal) throws HttpException, 
IOException
  +    {
  +        AclProperty acl = webdavResource.aclfindMethod(path);
  +        if (acl==null)
  +        {
  +            System.out.println("Error: PropFind didn't return an AclProperty!");
  +            return false;
  +        }
  +        Ace[] aces=acl.getAces();
  +
  +        if (debugLevel>5) {
  +            System.out.println();
  +            System.out.println("ACL from server");
  +            showAces(path, aces);
  +        }
  +        
  +        boolean found=false;
  +        Privilege privilege=new Privilege(namespace, permission, null);
  +        for (int i=0; i<aces.length; i++)
  +        {
  +            if (!aces[i].isProtected() && !aces[i].isInherited() && 
aces[i].getPrincipal().equals(principal))
  +            {
  +                if (debugLevel>5)
  +                    System.out.println("found ace");
  +                boolean removed = aces[i].removePrivilege(privilege);
  +                found = found || removed;
  +                if (removed)
  +                    System.out.println("Privilege removed");
  +            }
  +        }
  +        
  +        if (!found) 
  +        {
  +            System.out.println("Privilege not found");
  +            return false;
  +        }
  +        
  +        if (debugLevel>5) {
  +            System.out.println();
  +            System.out.println("ACL with updated privileges");
  +            showAces(path, aces);
  +        }
  +
  +        boolean success = webdavResource.aclMethod(path,aces);
  +    
  +        if (!success)
  +            System.err.println(webdavResource.getStatusMessage());    
   
           if (debugLevel>5) {
  -            //if (log.isDebugEnabled()) {
               acl = webdavResource.aclfindMethod(path);
               if (acl==null)
                   System.out.println("Error: PropFind didn't return an AclProperty!");
  -                     else 
  -                     {       
  -                     aces=acl.getAces();
  -                     System.out.println();
  -                     System.out.println("ACL from server after update");
  -                 showAces(path, aces);
  -                     }
  -        }
  -                     
  -             return success;
  -     }
  -
  -     private boolean removePermission(WebdavResource webdavResource, String 
namespace, String permission, String path, String principal) throws HttpException, 
IOException
  -     {
  -             AclProperty acl = webdavResource.aclfindMethod(path);
  -             if (acl==null)
  -             {
  -                     System.out.println("Error: PropFind didn't return an 
AclProperty!");
  -                     return false;
  -             }
  -             Ace[] aces=acl.getAces();
  -
  -             if (debugLevel>5) {
  -                    //if (log.isDebugEnabled()) {
  -             System.out.println();
  -                     System.out.println("ACL from server");
  -                 showAces(path, aces);
  -             }
  -             
  -             boolean found=false;
  -             Privilege privilege=new Privilege(namespace, permission, null);
  -             for (int i=0; i<aces.length; i++)
  -             {
  -                     if (!aces[i].isProtected() && !aces[i].isInherited() && 
aces[i].getPrincipal().equals(principal))
  -                     {
  -                             if (debugLevel>5)
  -                                    //if (log.isDebugEnabled())
  -                                    System.out.println("found ace");
  -                                boolean removed = 
aces[i].removePrivilege(privilege);
  -                             found = found || removed;
  -                             if (removed)
  -                                    System.out.println("Privilege removed");
  -                                //log.debug("privilege removed");
  -                     }
  -             }
  -             
  -             if (!found) 
  -             {
  -                     System.out.println("Privilege not found");
  -                     return false;
  -             }
  -             
  -             if (debugLevel>5) {
  -                    //if (log.isDebugEnabled()) {
  -                     System.out.println();
  -                     System.out.println("ACL with updated privileges");
  -                 showAces(path, aces);
  -             }
  -
  -             boolean success = webdavResource.aclMethod(path,aces);
  -     
  -             if (!success)
  -             System.err.println(webdavResource.getStatusMessage());  
  -
  -         if (debugLevel>5) {
  -                //if (log.isDebugEnabled()) {
  -                 acl = webdavResource.aclfindMethod(path);
  -                 if (acl==null)
  -                     System.out.println("Error: PropFind didn't return an 
AclProperty!");
  -                 else 
  -                 {   
  -                     aces=acl.getAces();
  -                     System.out.println();
  -                     System.out.println("ACL from server after update");
  -                     showAces(path, aces);
  -                 }
  -         }
  -                     
  -             return success;
  -     }
  -     
  -     private void showAces(String path, Ace[] aces)
  -     {
  -             System.out.println("ACL for " + path + ":");
  -             
System.out.println("------------------------------------------------------------");
  -             for (int i=0; i<aces.length ; i++) 
  -             {
  -                     Ace ace=aces[i];
  -                     System.out.println((!ace.isNegative()?"granted":"denied") + 
  -                             " to " + ace.getPrincipal() + " " + 
  -                             "   (" + (ace.isProtected()?"protected":"not 
protected") + ")" +
  -                             "   (" + (ace.isInherited()? ("inherited from '" + 
ace.getInheritedFrom() + "'"): "not inherited") +")");
  -             
  -                     Enumeration privileges=ace.enumeratePrivileges();
  -                     while (privileges.hasMoreElements())
  -                     {
  -                             Privilege priv=(Privilege)privileges.nextElement();
  -                             System.out.println("   " + priv.getNamespace() + 
priv.getName() + "   " + (priv.getParameter()==null?"":("("+priv.getParameter()+")")));
  -                     }
  -             }
  -             
System.out.println("------------------------------------------------------------");
  -     }
  -     
  -     private void showLocks(String path, Lock[] locks)
  -     {
  -             System.out.println("Locks for " + path + ":");
  -             
System.out.println("------------------------------------------------------------");
  -             for (int i=0; i<locks.length ; i++)
  -             {
  -                     int lockScope = locks[i].getLockScope();
  -                     if (lockScope==Lock.SCOPE_EXCLUSIVE) {
  -                             System.out.print("Exclusive ");
  -                     } 
  -                     else if (lockScope==Lock.SCOPE_SHARED) {
  -                             System.out.print("Shared ");
  -                     }
  -                     else if (lockScope==-1) {
  -                             System.out.print("Unknown scope ");
  -                     }
  -                     else {
  -                             System.out.println("!!! Internal error !!!");
  -                             return;
  -                     }
  -                     
  -                     int lockType = locks[i].getLockType();
  -                     if (lockType==Lock.TYPE_WRITE) {
  -                             System.out.println("write lock");
  -                     }
  -                     else if (lockType==-1) {
  -                             System.out.println("unknown type");
  -                     }
  -                     else {
  -                             System.out.println("!!! Internal error !!!");
  -                             return;
  -                     }
  -                     
  -                     int depth=locks[i].getDepth();
  -                     if (depth==DepthSupport.DEPTH_INFINITY) {
  -                             System.out.println("   depth: infinity");
  -                     }
  -                     else if (depth==-1) {
  -                             // unknown
  -                     }
  -                     else {
  -                             System.out.println("   depth: " + depth);
  -                     }                       
  -
  -                     String owner=locks[i].getOwner();
  -                     if (owner!=null) 
  -                             System.out.println("   owner: " + owner);
  -                             
  -                     long timeout=locks[i].getTimeout();
  -                     if (timeout!=-1)
  -                             System.out.println("   timeout: " + timeout);
  -                     
  -                     String token=locks[i].getLockToken();
  -                     if (token!=null) 
  -                             System.out.println("   token: " + token);
  -             }
  -     }
  +            else 
  +            {    
  +                aces=acl.getAces();
  +                  System.out.println();
  +                  System.out.println("ACL from server after update");
  +                showAces(path, aces);
  +            }
  +        }
  +            
  +        return success;
  +    }
  +    
  +    private void showAces(String path, Ace[] aces)
  +    {
  +        System.out.println("ACL for " + path + ":");
  +        
System.out.println("------------------------------------------------------------");
  +        for (int i=0; i<aces.length ; i++) 
  +        {
  +            Ace ace=aces[i];
  +            System.out.println((!ace.isNegative()?"granted":"denied") + 
  +                " to " + ace.getPrincipal() + " " + 
  +                "   (" + (ace.isProtected()?"protected":"not protected") + ")" +
  +                "   (" + (ace.isInherited()? ("inherited from '" + 
ace.getInheritedFrom() + "'"): "not inherited") +")");
  +        
  +            Enumeration privileges=ace.enumeratePrivileges();
  +            while (privileges.hasMoreElements())
  +            {
  +                Privilege priv=(Privilege)privileges.nextElement();
  +                System.out.println("   " + priv.getNamespace() + priv.getName() + " 
  " + (priv.getParameter()==null?"":("("+priv.getParameter()+")")));
  +            }
  +        }
  +        
System.out.println("------------------------------------------------------------");
  +    }
  +    
  +    private void showLocks(String path, Lock[] locks)
  +    {
  +        System.out.println("Locks for " + path + ":");
  +        
System.out.println("------------------------------------------------------------");
  +        for (int i=0; i<locks.length ; i++)
  +        {
  +            int lockScope = locks[i].getLockScope();
  +            if (lockScope==Lock.SCOPE_EXCLUSIVE) {
  +                System.out.print("Exclusive ");
  +            } 
  +            else if (lockScope==Lock.SCOPE_SHARED) {
  +                System.out.print("Shared ");
  +            }
  +            else if (lockScope==-1) {
  +                System.out.print("Unknown scope ");
  +            }
  +            else {
  +                System.out.println("!!! Internal error !!!");
  +                return;
  +            }
  +            
  +            int lockType = locks[i].getLockType();
  +            if (lockType==Lock.TYPE_WRITE) {
  +                System.out.println("write lock");
  +            }
  +            else if (lockType==-1) {
  +                System.out.println("unknown type");
  +            }
  +            else {
  +                System.out.println("!!! Internal error !!!");
  +                return;
  +            }
  +            
  +            int depth=locks[i].getDepth();
  +            if (depth==DepthSupport.DEPTH_INFINITY) {
  +                System.out.println("   depth: infinity");
  +            }
  +            else if (depth==-1) {
  +                // unknown
  +            }
  +            else {
  +                System.out.println("   depth: " + depth);
  +            }            
  +
  +            String owner=locks[i].getOwner();
  +            if (owner!=null) 
  +                System.out.println("   owner: " + owner);
  +                
  +            long timeout=locks[i].getTimeout();
  +            if (timeout!=-1)
  +                System.out.println("   timeout: " + timeout);
  +            
  +            String token=locks[i].getLockToken();
  +            if (token!=null) 
  +                System.out.println("   token: " + token);
  +        }
  +    }
   }
  
  
  


Reply via email to