pnever      2003/10/20 05:38:17

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        AclMethod.java ReportMethod.java LockMethod.java
               src/share/org/apache/slide/lock LockImpl.java
               src/share/org/apache/slide/common NamespaceConfig.java
               src/share/org/apache/slide/security SecurityImpl.java
               src/share/org/apache/slide/structure StructureImpl.java
               src/webdav/server/org/apache/slide/webdav/util
                        PropertyHelper.java XMLValue.java
  Log:
  Refactoring:
  users, groups and roles paths are controlled now solely by NamespaceConfig
  
  Revision  Changes    Path
  1.35      +4 -11     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java
  
  Index: AclMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- AclMethod.java    18 Oct 2003 16:30:29 -0000      1.34
  +++ AclMethod.java    20 Oct 2003 12:38:17 -0000      1.35
  @@ -447,14 +447,7 @@
               return "~";
           }
           else if (hasChild(principal, NamespaceCache.DEFAULT_NAMESPACE, 
E_UNAUTHENTICATED)) {
  -                     String userCollection = "/";
  -                     String configParam = 
token.getNamespaceConfig().getParameter(AclConstants.P_USER_COLLECTION);
  -             if ( configParam != null ) {
  -             if ( configParam.length() > 0 )
  -                userCollection =  userCollection + configParam +"/";
  -             }
  -            return token.getNamespaceConfig().getUsersPath() + userCollection +
  -                token.getNamespaceConfig().getGuestPath();
  +            return 
token.getNamespaceConfig().getUsersPath()+token.getNamespaceConfig().getGuestPath();
           }
           throw new JDOMException("<"+principal.getName()+"> element must 
contain either a "+
                                       "<"+E_HREF+">, "+
  
  
  
  1.59      +4 -11     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java
  
  Index: ReportMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- ReportMethod.java 13 Oct 2003 16:55:42 -0000      1.58
  +++ ReportMethod.java 20 Oct 2003 12:38:17 -0000      1.59
  @@ -1120,13 +1120,6 @@
           char seperator = '/';
           boolean self = false;
           
  -        String userPrefix = "/";
  -        String configParam = 
token.getNamespaceConfig().getParameter(AclConstants.P_USER_COLLECTION);
  -        if ( configParam != null ) {
  -            if ( configParam.length() > 0 )
  -                userpath = userpath + "/" + configParam +"/";
  -        }
  -        
           currentUri = req.getRequestURI();
           // check if self or principal-property is searched
           if ((principalProperty.getName()).equalsIgnoreCase(E_SELF)) {
  
  
  
  1.52      +5 -12     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java
  
  Index: LockMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- LockMethod.java   18 Sep 2003 11:01:07 -0000      1.51
  +++ LockMethod.java   20 Oct 2003 12:38:17 -0000      1.52
  @@ -431,18 +431,11 @@
                                                   + (MAX_TIMEOUT * 1000));
   
                       }
  -                    String userCollection = "/";
  -                    String configParam = 
namespaceConfig.getParameter(AclConstants.P_USER_COLLECTION);
  -                    if ( configParam != null ) {
  -                    if ( configParam.length() > 0 )
  -                        userCollection = "/" + configParam +"/";
  -                    }
   
                       SubjectNode credentialsSubject =
                           (SubjectNode) structure.retrieve
  -                        (slideToken, namespaceConfig.getUsersPath() + userCollection
  -                             + slideToken.getCredentialsToken()
  -                             .getPublicCredentials());
  +                        (slideToken, namespaceConfig.getUsersPath()
  +                             
+"/"+slideToken.getCredentialsToken().getPublicCredentials());
   
                       NodeLock lockToken = null;
   
  
  
  
  1.35      +5 -16     jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java
  
  Index: LockImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- LockImpl.java     18 Oct 2003 16:30:29 -0000      1.34
  +++ LockImpl.java     20 Oct 2003 12:38:17 -0000      1.35
  @@ -410,22 +410,11 @@
       private String computeSubjectUriFromPrincipal(SlideToken token) {
           
           String result;
  -        String configParam = namespaceConfig.getParameter("user_collection");
  -        
  -        String userCollection;
  -        if ( configParam != null && configParam.length() > 0) {
  -            userCollection =  "/" + configParam;
  -        } else {
  -            userCollection =  "/";
  -        }
  -        
  -        
           String userId = token.getCredentialsToken().getPublicCredentials();
           if (userId.equals("/")) userId = "";
           else userId = "/" + userId;
           
  -        result = namespaceConfig.getUsersPath() + userCollection + userId;
  -        //        System.out.println("##### Subject URI = " + result);
  +        result = namespaceConfig.getUsersPath()+userId;
           return result;
       }
       
  
  
  
  1.30      +79 -6     
jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java
  
  Index: NamespaceConfig.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- NamespaceConfig.java      18 Oct 2003 16:30:29 -0000      1.29
  +++ NamespaceConfig.java      20 Oct 2003 12:38:17 -0000      1.30
  @@ -100,7 +100,15 @@
   
   
       /** generic action nodes */
  -    public static final ActionNode DEFAULT_ACTION = new ActionNode();
  +    public static final ActionNode DEFAULT_ACTION = new ActionNode("default");
  +    public static final ActionNode ALL_ACTION = new ActionNode("all");
  +    
  +    
  +    /** generic subject nodes */
  +    public static final SubjectNode DEFAULT_SUBJECT = new SubjectNode("default");
  +    public static final SubjectNode ALL_SUBJECT = new SubjectNode("all");
  +    public static final SubjectNode OWNER_SUBJECT = new SubjectNode("owner");
  +    public static final SubjectNode GUEST_SUBJECT = new SubjectNode("guest");
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -226,6 +234,10 @@
        */
       protected String usersPath = null;
   
  +    protected String resolvedUsersPath = null;
  +    protected String resolvedGroupsPath = null;
  +    protected String resolvedRolesPath = null;
  +    
   
       /**
        * Guest user path.
  @@ -500,7 +512,68 @@
        * @return String Users path
        */
       public String getUsersPath() {
  -        return usersPath;
  +        // TODO: get rid of user_collection parameter
  +        if (resolvedUsersPath == null) {
  +            if (usersPath == null || "/".equals(usersPath)) {
  +                resolvedUsersPath = "";
  +            }
  +            else {
  +                String ucoll = getParameter("user_collection");
  +                if (ucoll != null && ucoll.length() > 0) {
  +                    if (!ucoll.startsWith("/")) {
  +                        ucoll = "/"+ucoll;
  +                    }
  +                    resolvedUsersPath = usersPath+ucoll;
  +                }
  +            }
  +        }
  +        return resolvedUsersPath;
  +    }
  +    
  +    /**
  +     * Groups path accessor.
  +     *
  +     * @return String Groups path
  +     */
  +    public String getGroupsPath() {
  +        if (resolvedGroupsPath == null) {
  +            if (usersPath == null || "/".equals(usersPath)) {
  +                resolvedGroupsPath = "";
  +            }
  +            else {
  +                String gcoll = getParameter("group_collection");
  +                if (gcoll != null && gcoll.length() > 0) {
  +                    if (!gcoll.startsWith("/")) {
  +                        gcoll = "/"+gcoll;
  +                    }
  +                    resolvedGroupsPath = usersPath+gcoll;
  +                }
  +            }
  +        }
  +        return resolvedGroupsPath;
  +    }
  +    
  +    /**
  +     * Roles path accessor.
  +     *
  +     * @return String Roles path
  +     */
  +    public String getRolesPath() {
  +        if (resolvedRolesPath == null) {
  +            if (usersPath == null || "/".equals(usersPath)) {
  +                resolvedRolesPath = "";
  +            }
  +            else {
  +                String rcoll = getParameter("role_collection");
  +                if (rcoll != null && rcoll.length() > 0) {
  +                    if (!rcoll.startsWith("/")) {
  +                        rcoll = "/"+rcoll;
  +                    }
  +                    resolvedRolesPath = usersPath+rcoll;
  +                }
  +            }
  +        }
  +        return resolvedRolesPath;
       }
   
   
  
  
  
  1.39      +5 -12     
jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java
  
  Index: SecurityImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- SecurityImpl.java 18 Oct 2003 16:30:29 -0000      1.38
  +++ SecurityImpl.java 20 Oct 2003 12:38:17 -0000      1.39
  @@ -857,15 +857,8 @@
               principalPath = namespaceConfig.getGuestPath();
           }
           
  -        String userPrefix = "/";
  -        String configParam = namespaceConfig.getParameter("user_collection");
  -        if ( configParam != null ) {
  -            if ( configParam.length() > 0 )
  -                userPrefix = "/" + configParam +"/";
  -        }
  -        
           Uri subjectUri = namespace.getUri
  -            (token, namespaceConfig.getUsersPath() + userPrefix + principalPath);
  +            (token, namespaceConfig.getUsersPath()+"/"+principalPath);
           
           try {
               return subjectUri.getStore().retrieveObject(subjectUri);
  
  
  
  1.34      +6 -6      
jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java
  
  Index: StructureImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- StructureImpl.java        17 Oct 2003 16:47:26 -0000      1.33
  +++ StructureImpl.java        20 Oct 2003 12:38:17 -0000      1.34
  @@ -374,8 +374,8 @@
                       // object in the configuration files.
                       // This would then be the default behavior.
                       NodePermission grantedPermission = null;
  -                    String userUri = namespaceConfig.getUsersPath() + "/"
  -                        + token.getCredentialsToken().getPublicCredentials();
  +                    String userUri = namespaceConfig.getUsersPath()
  +                        +"/"+token.getCredentialsToken().getPublicCredentials();
                       Domain.debug("Checking basic permissions on new object");
                       /*
                        try {
  
  
  
  1.56      +29 -53    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java
  
  Index: PropertyHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- PropertyHelper.java       16 Oct 2003 10:01:07 -0000      1.55
  +++ PropertyHelper.java       20 Oct 2003 12:38:17 -0000      1.56
  @@ -1076,20 +1076,31 @@
           List excludeList = new ArrayList();
           
           String usersPath = 
truncateLeadingSlash(nsaToken.getNamespaceConfig().getUsersPath());
  -        Element excludeElement = new Element(DaslConstants.E_EXCLUDE, 
NamespaceCache.SLIDE_NAMESPACE);
  -        excludeElement.setText(usersPath);
  -        excludeList.add(excludeElement);
  +        addExcludeElement(usersPath, excludeList);
  +        
  +        String groupsPath = 
truncateLeadingSlash(nsaToken.getNamespaceConfig().getGroupsPath());
  +        addExcludeElement(groupsPath, excludeList);
  +        
  +        String rolesPath = 
truncateLeadingSlash(nsaToken.getNamespaceConfig().getRolesPath());
  +        addExcludeElement(rolesPath, excludeList);
           
           Iterator historyPathIterator = 
HistoryPathHandler.getHistoryPathHandler().getResolvedHistoryPaths().iterator();
           while (historyPathIterator.hasNext()) {
  -            excludeElement = new Element(DaslConstants.E_EXCLUDE, 
NamespaceCache.SLIDE_NAMESPACE);
  -            
excludeElement.setText(truncateLeadingSlash(historyPathIterator.next().toString()));
  -            excludeList.add(excludeElement);
  +            String path = 
truncateLeadingSlash(historyPathIterator.next().toString());
  +            addExcludeElement(path, excludeList);
           }
           
           return excludeList;
       }
       
  +    private void addExcludeElement(String path, List excludeList) {
  +        if (path != null && path.length() > 0) {
  +            Element excludeElement = new Element(DaslConstants.E_EXCLUDE, 
NamespaceCache.SLIDE_NAMESPACE);
  +            excludeElement.setText(path);
  +            excludeList.add(excludeElement);
  +        }
  +    }
  +    
       /**
        * Returns an XMLValue containing <code>&lt;href&gt;</code> elements
        * with the URI of the VCRs in the workspace identified the given
  @@ -2040,44 +2051,15 @@
        * @throws   JDOMException
        */
       public XMLValue computePrincipalCollectionSet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
  -        
           XMLValue xmlValue = new XMLValue();
  -        
  -        NamespaceConfig config = nsaToken.getNamespaceConfig();
  -        Element href;
  -        String userCollStr = config.getParameter(P_USER_COLLECTION);
  -        String groupCollStr = config.getParameter(P_GROUP_COLLECTION);
  -        String roleCollStr = config.getParameter(P_ROLE_COLLECTION);
  -        if (userCollStr != null && userCollStr.length() > 0) {
  -            if (!userCollStr.startsWith("/")) {
  -                userCollStr = "/"+userCollStr;
  -            }
  -            href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  -            href.setText(getAbsoluteURL(null, contextPath, 
config.getUsersPath()+userCollStr));
  -            xmlValue.add(href);
  -            if (groupCollStr != null && groupCollStr.length() > 0) {
  -                if (!groupCollStr.startsWith("/")) {
  -                    groupCollStr = "/"+groupCollStr;
  -                }
  -                href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  -                href.setText(getAbsoluteURL(null, contextPath, 
config.getUsersPath()+groupCollStr));
  -                xmlValue.add(href);
  -            }
  -            if (roleCollStr != null && roleCollStr.length() > 0) {
  -                if (!roleCollStr.startsWith("/")) {
  -                    roleCollStr = "/"+roleCollStr;
  -                }
  -                href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  -                href.setText(getAbsoluteURL(null, contextPath, 
config.getUsersPath()+roleCollStr));
  -                xmlValue.add(href);
  -            }
  +        NamespaceConfig namespaceConfig = nsaToken.getNamespaceConfig();
  +        xmlValue.addHref(getAbsoluteURL(null, contextPath, 
namespaceConfig.getUsersPath()));
  +        if (namespaceConfig.getGroupsPath() != null) {
  +            xmlValue.addHref(getAbsoluteURL(null, contextPath, 
namespaceConfig.getGroupsPath()));
           }
  -        else {
  -            href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  -            href.setText(getAbsoluteURL(null, contextPath, config.getUsersPath()));
  -            xmlValue.add(href);
  +        if (namespaceConfig.getRolesPath() != null) {
  +            xmlValue.addHref(getAbsoluteURL(null, contextPath, 
namespaceConfig.getRolesPath()));
           }
  -        
           return xmlValue;
       }
       
  @@ -2130,23 +2112,17 @@
           XMLValue xmlValue = new XMLValue();
           String userHref;
           NamespaceConfig config = nsaToken.getNamespaceConfig();
  -        String userCollection = config.getParameter(USER_COLLECTION);
           if ((userProperty != null) && (userProperty.getValue()!=null) &&
                   (!"".equals(userProperty.getValue().toString()))) {
               
  -            if (userCollection == null){
  -                userHref = contextPath + config.getUsersPath() + "/" + 
userProperty.getValue().toString();
  -            } else {
  -                userHref = contextPath + config.getUsersPath() + "/" + 
userCollection + "/" + userProperty.getValue().toString();
  -            }
  +            userHref = contextPath + config.getUsersPath() + "/" + 
userProperty.getValue().toString();
  +            
           } else {
               userHref =  contextPath + config.getUsersPath();
               if ( config.getGuestPath() != null && !config.getGuestPath().equals("") 
)
                   userHref = userHref + "/" + config.getGuestPath();
           }
  -        Element href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  -        href.setText(userHref);
  -        xmlValue.add(href);
  +        xmlValue.addHref(userHref);
           return xmlValue;
       }
       
  
  
  
  1.13      +20 -10    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/XMLValue.java
  
  Index: XMLValue.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/XMLValue.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLValue.java     14 Aug 2003 14:41:45 -0000      1.12
  +++ XMLValue.java     20 Oct 2003 12:38:17 -0000      1.13
  @@ -69,6 +69,7 @@
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  +import org.apache.slide.content.NodeProperty;
   import org.jdom.CDATA;
   import org.jdom.Comment;
   import org.jdom.Document;
  @@ -93,13 +94,13 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Ralf Stuckert</a>
    **/
  -public class XMLValue implements Cloneable, Comparable {
  +public class XMLValue implements Cloneable, Comparable, WebdavConstants {
       
       /**
        * Constant for the message of the IllegalArgumentException that may be
        * thrown in method [EMAIL PROTECTED] #add add()}.
        */
  -
  +    
       public static final String ELEMENT_MUST_NOT_BE_NULL = "'null' Element is not 
allowed";
       
       /**
  @@ -299,7 +300,10 @@
               Iterator iterator = content.iterator();
               while (iterator.hasNext()) {
                   Object o = iterator.next();
  -                if( o instanceof Element ) {
  +                if( o == null ) {
  +                    throw new IllegalArgumentException(ELEMENT_MUST_NOT_BE_NULL);
  +                }
  +                else if( o instanceof Element ) {
                       add((Element)o);
                   }
                   else if( o instanceof Text ) {
  @@ -377,6 +381,12 @@
           }
       }
       
  +    public void addHref(String path) {
  +        Element href = new Element(E_HREF, 
NodeProperty.NamespaceCache.DEFAULT_NAMESPACE);
  +        href.setText(path);
  +        add(href);
  +    }
  +    
       /**
        * Returns an iterator of JDOM Elements.
        *
  @@ -558,7 +568,7 @@
       String getTextValue() {
           Iterator it = elementList.iterator();
           StringBuffer sb = new StringBuffer();
  -
  +        
           while (it.hasNext()) {
               Object o = it.next();
               if (o instanceof Element) {
  @@ -567,7 +577,7 @@
           }
           return sb.toString();
       }
  -
  +    
       /**
        * compares the concatenated Text values of all Elements in elementList
        *
  @@ -577,7 +587,7 @@
        *
        */
       public int compareTo (Object o) {
  -
  +        
           String s1 = getTextValue();
           String s2 = ((XMLValue)o).getTextValue();
           return s1.compareTo (s2);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to