juergen     02/05/14 23:41:59

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        PropertyHelper.java
  Log:
  Use DAV: namespace instead of default namespace.
  Added various compute..() methods for properties that have been computed in the 
PropertyRetrieverImpl so far.
  (ralf)
  
  Revision  Changes    Path
  1.20      +875 -42   
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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- PropertyHelper.java       8 May 2002 16:04:33 -0000       1.19
  +++ PropertyHelper.java       15 May 2002 06:41:59 -0000      1.20
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
 1.19 2002/05/08 16:04:33 pnever Exp $
  - * $Revision: 1.19 $
  - * $Date: 2002/05/08 16:04:33 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
 1.20 2002/05/15 06:41:59 juergen Exp $
  + * $Revision: 1.20 $
  + * $Date: 2002/05/15 06:41:59 $
    *
    * ====================================================================
    *
  @@ -75,6 +75,7 @@
   import org.apache.slide.common.Domain;
   import org.apache.slide.common.SlideToken;
   import org.apache.slide.common.NamespaceAccessToken;
  +import org.apache.slide.common.NamespaceConfig;
   import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.common.SlideException;
   
  @@ -85,10 +86,19 @@
   import org.apache.slide.content.Content;
   import org.apache.slide.content.RevisionDescriptorNotFoundException;
   
  +import org.apache.slide.lock.NodeLock;
  +import org.apache.slide.lock.Lock;
  +import org.apache.slide.lock.LockTokenNotFoundException;
  +
   import org.apache.slide.structure.LinkedObjectNotFoundException;
   import org.apache.slide.structure.ObjectNotFoundException;
  +import org.apache.slide.structure.SubjectNode;
  +import org.apache.slide.structure.ObjectNode;
  +import org.apache.slide.structure.Structure;
   
   import org.apache.slide.security.AccessDeniedException;
  +import org.apache.slide.security.Security;
  +import org.apache.slide.security.NodePermission;
   
   import org.apache.slide.lock.ObjectLockedException;
   
  @@ -106,7 +116,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
    */
   
  -public class PropertyHelper extends AbstractWebdavHelper implements 
DeltavConstants, AclConstants, DaslConstants {
  +public class PropertyHelper extends AbstractWebdavHelper implements 
WebdavConstants, DeltavConstants, AclConstants, DaslConstants {
       
       
       /**
  @@ -192,17 +202,17 @@
               try {
                   if( resourceKind instanceof VersionHistory ) {
                   rtvv.append(
  -                    xmlOut.outputString(new Element(E_VERSION_HISTORY, 
defNamespace)) );
  +                        xmlOut.outputString(new Element(E_VERSION_HISTORY, 
davNamespace)) );
                   rtvv.append(
  -                    xmlOut.outputString(new Element(E_COLLECTION, defNamespace)) );
  +                        xmlOut.outputString(new Element(E_COLLECTION, 
davNamespace)) );
               }
                   if( resourceKind instanceof DeltavCompliantCollection ) {
                       rtvv.append(
  -                        xmlOut.outputString(new Element(E_COLLECTION, 
defNamespace)) );
  +                        xmlOut.outputString(new Element(E_COLLECTION, 
davNamespace)) );
                   }
                   if( resourceKind instanceof Activity ) {
                       rtvv.append(
  -                        xmlOut.outputString(new Element(E_ACTIVITY, defNamespace)) 
);
  +                        xmlOut.outputString(new Element(E_ACTIVITY, davNamespace)) 
);
                   }
               }
               catch( Exception x ) {
  @@ -215,8 +225,8 @@
               StringBuffer smsv = new StringBuffer();
               while( i.hasNext() ) {
                   String m = (String) i.next();
  -                Element sm = new Element( E_SUPPORTED_METHOD, defNamespace );
  -                Attribute na = new Attribute( A_NAME, m, defNamespace );
  +                Element sm = new Element( E_SUPPORTED_METHOD, davNamespace );
  +                Attribute na = new Attribute( A_NAME, m, davNamespace );
                   sm.setAttribute( na );
                   try {
                       smsv.append( xmlOut.outputString(sm) );
  @@ -230,8 +240,8 @@
               StringBuffer spsv = new StringBuffer();
               while( i.hasNext() ) {
                   String p = (String) i.next();
  -                Element sp = new Element( E_SUPPORTED_LIVE_PROPERTY, defNamespace );
  -                Element na = new Element( E_NAME, defNamespace );
  +                Element sp = new Element( E_SUPPORTED_LIVE_PROPERTY, davNamespace );
  +                Element na = new Element( E_NAME, davNamespace );
                   na.addContent( p );
                   sp.addContent( na );
                   try {
  @@ -246,8 +256,8 @@
               StringBuffer srsv = new StringBuffer();
               while( i.hasNext() ) {
                   String r = (String) i.next();
  -                Element sr = new Element( E_SUPPORTED_REPORT, defNamespace );
  -                Element na = new Element( E_NAME, defNamespace );
  +                Element sr = new Element( E_SUPPORTED_REPORT, davNamespace );
  +                Element na = new Element( E_NAME, davNamespace );
                   na.addContent( r );
                   sr.addContent( na );
                   try {
  @@ -262,21 +272,21 @@
               String avconf = nsaToken.getNamespaceConfig().getAutoVersion();
               
               if( E_CHECKOUT_CHECKIN.equals(avconf) ) {
  -                avv = new Element( E_CHECKOUT_CHECKIN, defNamespace );
  +                avv = new Element( E_CHECKOUT_CHECKIN, davNamespace );
               }
               else if( E_CHECKOUT_UNLOCKED_CHECKIN.equals(avconf) ) {
  -                avv = new Element( E_CHECKOUT_UNLOCKED_CHECKIN, defNamespace );
  +                avv = new Element( E_CHECKOUT_UNLOCKED_CHECKIN, davNamespace );
               }
               else if( E_CHECKOUT.equals(avconf) ) {
  -                avv = new Element( E_CHECKOUT, defNamespace );
  +                avv = new Element( E_CHECKOUT, davNamespace );
               }
               else if( E_LOCKED_CHECKOUT.equals(avconf) ) {
  -                avv = new Element( E_LOCKED_CHECKOUT, defNamespace );
  +                avv = new Element( E_LOCKED_CHECKOUT, davNamespace );
               }
               else {
                   Domain.warn( "Auto-version not configured properly; using "
                                +E_CHECKOUT_CHECKIN );
  -                avv = new Element( E_CHECKOUT_CHECKIN, defNamespace );
  +                avv = new Element( E_CHECKOUT_CHECKIN, davNamespace );
               }
               
               try {
  @@ -291,15 +301,15 @@
               String cfconf = nsaToken.getNamespaceConfig().getCheckoutFork();
               
               if( E_FORBIDDEN.equals(cfconf) ) {
  -                cfv = new Element( E_FORBIDDEN, defNamespace );
  +                cfv = new Element( E_FORBIDDEN, davNamespace );
               }
               else if( E_DISCOURAGED.equals(cfconf) ) {
  -                cfv = new Element( E_DISCOURAGED, defNamespace );
  +                cfv = new Element( E_DISCOURAGED, davNamespace );
               }
               else {
                   Domain.warn( "Checkout-fork not configured properly; using "
                                +E_FORBIDDEN );
  -                cfv = new Element( E_FORBIDDEN, defNamespace );
  +                cfv = new Element( E_FORBIDDEN, davNamespace );
               }
               
               try {
  @@ -314,15 +324,15 @@
               String cfconf = nsaToken.getNamespaceConfig().getCheckinFork();
               
               if( E_FORBIDDEN.equals(cfconf) ) {
  -                cfv = new Element( E_FORBIDDEN, defNamespace );
  +                cfv = new Element( E_FORBIDDEN, davNamespace );
               }
               else if( E_DISCOURAGED.equals(cfconf) ) {
  -                cfv = new Element( E_DISCOURAGED, defNamespace );
  +                cfv = new Element( E_DISCOURAGED, davNamespace );
               }
               else {
                   Domain.warn( "Checkin-fork not configured properly; using "
                                +E_FORBIDDEN );
  -                cfv = new Element( E_FORBIDDEN, defNamespace );
  +                cfv = new Element( E_FORBIDDEN, davNamespace );
               }
               
               try {
  @@ -356,7 +366,7 @@
       public Object createHrefValue( String uri ) {
           String result = "";
           
  -        Element href = new Element( E_HREF, defNamespace );
  +        Element href = new Element( E_HREF, davNamespace );
           href.addContent( uri );
           try {
               result = xmlOut.outputString( href );
  @@ -385,11 +395,11 @@
       public Object createHrefSetValue( String rootElement, List uriList ) {
           String result = "";
           
  -        Element root = new Element( rootElement, defNamespace );
  +        Element root = new Element( rootElement, davNamespace );
           Iterator i = uriList.iterator();
           
           while( i.hasNext() ) {
  -            Element href = new Element( E_HREF, defNamespace );
  +            Element href = new Element( E_HREF, davNamespace );
               href.addContent( (String)i.next() );
               root.addContent( href );
           }
  @@ -564,6 +574,31 @@
               property = new NodeProperty(propertyName, 
computeWorkspaceCheckoutSet(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
           }
           
  +        else if (P_LOCKDISCOVERY.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeLockDiscovery(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
  +        }
  +        else if (P_SUPPORTEDLOCK.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeSupportedlock(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
  +        }
  +        else if (P_SUPPORTED_PRIVILEGE_SET.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeSupportedPrivilegeSet(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
  +        }
  +        else if (P_CURRENT_USER_PRIVILEGE_SET.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeCurrentuserPrivilegeSet(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
  +        }
  +        else if (P_ACL.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeAcl(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
  +        }
  +        else if (P_ACL_SEMANTICS.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeAclSemantics(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
  +        }
  +        else if (P_PRINCIPAL_COLLECTION_SET.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computePrincipalCollectionSet(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
  +        }
  +        else if (P_OWNER.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeOwner(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
  +        }
  +        
           return property;
       }
       
  @@ -591,7 +626,7 @@
       public XMLValue computeSuccessorSet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException {
           
           XMLValue xmlValue = new XMLValue();
  -        Element hrefElement = new Element(E_HREF, defNamespace);
  +        Element hrefElement = new Element(E_HREF, davNamespace);
           NodeRevisionDescriptor successorRevisionDescriptor = null;
           NodeRevisionNumber successorRevisionNumber = null;
           Enumeration successorEnum = 
revisionDescriptors.getSuccessors(revisionDescriptor.getRevisionNumber());
  @@ -640,12 +675,12 @@
           XMLValue xmlValue = new XMLValue();
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           if (resourceKind instanceof Version) {
  -            Element element = new Element(E_HREF, defNamespace);
  +            Element element = new Element(E_HREF, davNamespace);
               element.setText(getAbsoluteURL(serverURL, contextPath, 
revisionDescriptors.getUri()));
               xmlValue.add(element);
           }
           else if (resourceKind instanceof CheckedInVersionControlled) {
  -            Element element = new Element(E_HREF, defNamespace);
  +            Element element = new Element(E_HREF, davNamespace);
               String checkedInHref = 
revisionDescriptor.getProperty(P_CHECKED_IN).getValue().toString();
               String checkedInUri = ((Element)new 
XMLValue(checkedInHref).iterator().next()).getText();
               UriHandler uriHandler = UriHandler.getUriHandler(nsaToken, 
checkedInUri);
  @@ -653,7 +688,7 @@
               xmlValue.add(element);
           }
           else if (resourceKind instanceof CheckedOutVersionControlled) {
  -            Element element = new Element(E_HREF, defNamespace);
  +            Element element = new Element(E_HREF, davNamespace);
               String checkedOutHref = 
revisionDescriptor.getProperty(P_CHECKED_OUT).getValue().toString();
               String checkedOutUri = ((Element)new 
XMLValue(checkedOutHref).iterator().next()).getText();
               UriHandler uriHandler = UriHandler.getUriHandler(nsaToken, 
checkedOutUri);
  @@ -692,7 +727,7 @@
           
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           if (resourceKind instanceof VersionHistory) {
  -            Element element = new Element(E_HREF, defNamespace);
  +            Element element = new Element(E_HREF, davNamespace);
               StringBuffer buffer = new StringBuffer(revisionDescriptors.getUri());
               if ( ! revisionDescriptors.getUri().endsWith("/") ) {
                   buffer.append("/");
  @@ -742,7 +777,7 @@
           Iterator iterator = supportedMethodNames.iterator();
           Element supportedMethod = null;
           while (iterator.hasNext()) {
  -            supportedMethod = new Element(E_SUPPORTED_METHOD);
  +            supportedMethod = new Element(E_SUPPORTED_METHOD, davNamespace);
               supportedMethod.setAttribute(new Attribute(E_NAME, 
(String)iterator.next()));
               xmlValue.add(supportedMethod);
           }
  @@ -791,10 +826,10 @@
           Element propertyElement = null;
           while (iterator.hasNext()) {
               
  -            supportedLivePropertyElement = new Element(E_SUPPORTED_LIVE_PROPERTY);
  -            propElement = new Element(E_PROP);
  +            supportedLivePropertyElement = new Element(E_SUPPORTED_LIVE_PROPERTY, 
davNamespace);
  +            propElement = new Element(E_PROP, davNamespace);
               supportedLivePropertyElement.addContent(propElement);
  -            propertyElement = new Element((String)iterator.next());
  +            propertyElement = new Element((String)iterator.next(), davNamespace);
               propElement.addContent(propertyElement);
               xmlValue.add(supportedLivePropertyElement);
           }
  @@ -843,10 +878,10 @@
           Element propertyElement = null;
           while (iterator.hasNext()) {
               
  -            supportedReportElement = new Element(E_SUPPORTED_REPORT);
  -            reportElement = new Element(E_REPORT);
  +            supportedReportElement = new Element(E_SUPPORTED_REPORT, davNamespace);
  +            reportElement = new Element(E_REPORT, davNamespace);
               supportedReportElement.addContent(reportElement);
  -            propertyElement = new Element((String)iterator.next());
  +            propertyElement = new Element((String)iterator.next(), davNamespace);
               reportElement.addContent(propertyElement);
               xmlValue.add(supportedReportElement);
           }
  @@ -922,7 +957,7 @@
               Element href = null;
               while (queryResultIterator.hasNext()) {
                   requestedResource = (RequestedResource)queryResultIterator.next();
  -                href = new Element(E_HREF, defNamespace);
  +                href = new Element(E_HREF, davNamespace);
                   href.setText(getAbsoluteURL(serverURL, contextPath, 
requestedResource.getInternalHref()));
                   xmlValue.add(href);
               }
  @@ -1013,7 +1048,7 @@
               Element hrefElement = null;
               while (queryResultIterator.hasNext()) {
                   requestedResource = (RequestedResource)queryResultIterator.next();
  -                hrefElement = new Element(E_HREF, defNamespace);
  +                hrefElement = new Element(E_HREF, davNamespace);
                   hrefElement.setText(getAbsoluteURL(serverURL, contextPath, 
requestedResource.getInternalHref()));
                   xmlValue.add(hrefElement);
               }
  @@ -1061,6 +1096,804 @@
           return workspaceCheckoutSetQueryElement;
           }
           
  +    /**
  +     * Returns an XMLValue containing the value of the 
<code>&lt;lockdiscovery&gt;</code>
  +     * property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;lockdiscovery&gt;</code> property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeLockDiscovery(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
  +        
  +        XMLValue xmlValue = new XMLValue();
  +        
  +        Lock lock = nsaToken.getLockHelper();
  +        Security security = nsaToken.getSecurityHelper();
  +        
  +        NodeLock objectLockToken = null;
  +        Enumeration lockTokens = lock.enumerateLocks(sToken, 
revisionDescriptors.getUri(), true);
  +        if (lockTokens.hasMoreElements()) {
  +            objectLockToken = (NodeLock) lockTokens.nextElement();
  +        }
  +        
  +        if (objectLockToken != null) {
  +            
  +            Element activelock = new Element(E_ACTIVELOCK, davNamespace);
  +            Element locktype = new Element(E_LOCKTYPE, davNamespace);
  +            activelock.addContent(locktype);
  +            Element write = new Element(E_WRITE, davNamespace);
  +            locktype.addContent(write);
  +            Element lockscope = new Element(E_LOCKSCOPE, davNamespace);
  +            activelock.addContent(lockscope);
  +            Element lockscopeValue = null;
  +            if (objectLockToken.isExclusive()) {
  +                lockscopeValue = new Element(E_EXCLUSIVE, davNamespace);
  +            } else {
  +                lockscopeValue = new Element(E_SHARED, davNamespace);
  +            }
  +            lockscope.addContent(lockscopeValue);
  +            Element depth = new Element(E_DEPTH, davNamespace);
  +            activelock.addContent(depth);
  +            if (objectLockToken.isInheritable()) {
  +                depth.setText("infinity");
  +            } else {
  +                depth.setText("0");
  +            }
  +            Element owner = new Element(E_OWNER, davNamespace);
  +            activelock.addContent(owner);
  +            /* We need to write this as data (i.e. a CDATA section) because
  +             * we don't know what the subjectUri (i.e. username) might
  +             * contain. The webdav RFC leaves us completely free to
  +             * put whatever we want inside the owner element.
  +             */
  +            owner.setText(getAbsoluteURL(serverURL, contextPath, 
objectLockToken.getSubjectUri()));
  +            Element timeout = new Element(E_TIMEOUT, davNamespace);
  +            activelock.addContent(timeout);
  +            timeout.setText("Second-"
  +                                + (new 
Long((objectLockToken.getExpirationDate().getTime()
  +                                                 - (new Date()).getTime())/1000))
  +                                .toString());
  +            Element locktoken = new Element(E_LOCKTOKEN, davNamespace);
  +            activelock.addContent(locktoken);
  +            Element href = new Element(E_HREF, davNamespace);
  +            locktoken.addContent(href);
  +            // Put here the token Id
  +            boolean isOwner = false;
  +            try {
  +                String subjectUri = security.getPrincipal(sToken).getUri();
  +                if (objectLockToken.getSubjectUri().startsWith(subjectUri))
  +                    isOwner = true;
  +            } catch (Exception e) {
  +            }
  +            if (isOwner || sToken.checkLockToken(objectLockToken.getLockId())) {
  +                href.setText("opaquelocktoken:" + objectLockToken.getLockId());
  +            } else {
  +                href.setText("opaquelocktoken:faketoken");
  +            }
  +            
  +            xmlValue.add(activelock);
  +        }
  +        return xmlValue;
  +    }
  +    
  +    /**
  +     * Returns an XMLValue containing the value of the 
<code>&lt;supportedlock&gt;</code>
  +     * property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;supportedlock&gt;</code> property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeSupportedlock(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
  +        
  +        XMLValue xmlValue = new XMLValue();
  +        
  +        Element lockentry = new Element(E_LOCKENTRY, davNamespace);
  +        Element lockscope = new Element(E_LOCKSCOPE, davNamespace);
  +        lockentry.addContent(lockscope);
  +        Element exclusive = new Element(E_EXCLUSIVE, davNamespace);
  +        lockscope.addContent(exclusive);
  +        Element locktype = new Element(E_LOCKTYPE, davNamespace);
  +        lockentry.addContent(locktype);
  +        Element write = new Element(E_WRITE, davNamespace);
  +        locktype.addContent(write);
  +        xmlValue.add(lockentry);
  +        
  +        lockentry = new Element(E_LOCKENTRY, davNamespace);
  +        lockscope = new Element(E_LOCKSCOPE, davNamespace);
  +        lockentry.addContent(lockscope);
  +        Element shared = new Element(E_SHARED, davNamespace);
  +        lockscope.addContent(shared);
  +        locktype = new Element(E_LOCKTYPE, davNamespace);
  +        lockentry.addContent(locktype);
  +        write = new Element(E_WRITE, davNamespace);
  +        locktype.addContent(write);
  +        xmlValue.add(lockentry);
  +        
  +        return xmlValue;
  +    }
  +    
  +    
  +    /**
  +     * Returns an XMLValue containing the value of the 
<code>&lt;supported-privilege-set&gt;</code>
  +     * property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;supported-privilege-set&gt;</code> 
property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeSupportedPrivilegeSet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
  +        
  +        XMLValue xmlValue = new XMLValue();
  +        
  +        Element supportedPrivilege = new Element(E_SUPPORTED_PRIVILEGE, 
davNamespace);
  +        supportedPrivilege.addContent(createPrivilege(E_ALL));
  +        supportedPrivilege.addContent(createDescription("Any operation"));
  +        supportedPrivilege.addContent(createPrivilege(E_READ));
  +        supportedPrivilege.addContent(createDescription("Read any object"));
  +        xmlValue.add(supportedPrivilege);
  +        
  +        
  +        supportedPrivilege = new Element(E_SUPPORTED_PRIVILEGE, davNamespace);
  +        supportedPrivilege.addContent(createPrivilege(E_WRITE));
  +        supportedPrivilege.addContent(createDescription("Write any object"));
  +        supportedPrivilege.addContent(createPrivilege(E_READ_ACL));
  +        supportedPrivilege.addContent(createDescription("Read the ACL"));
  +        xmlValue.add(supportedPrivilege);
  +        
  +        
  +        supportedPrivilege = new Element(E_SUPPORTED_PRIVILEGE, davNamespace);
  +        supportedPrivilege.addContent(createPrivilege(E_WRITE_ACL));
  +        supportedPrivilege.addContent(createDescription("Write the ACL"));
  +        xmlValue.add(supportedPrivilege);
  +        
  +        return xmlValue;
  +    }
  +    
  +    /**
  +     * Creates a <code>&lt;privilege&gt;</code> element containing an
  +     * element with the given <code>privilegeName</code>.
  +     *
  +     * @param      privilegeName  the name of the privilege.
  +     *
  +     * @return     the <code>&lt;privilege&gt;</code> element.
  +     */
  +    private Element createPrivilege(String privilegeName) {
  +        return createPrivilege(privilegeName, true);
  +    }
  +    
  +    /**
  +     * Creates a <code>&lt;privilege&gt;</code> element containing an
  +     * element with the given <code>privilegeName</code>.
  +     *
  +     * @param      privilegeName    the name of the privilege.
  +     * @param      useDavNamespace  if <code>true</code> the <code>DAV:</code>
  +     *                              namespace will be used for the contained 
element,
  +     *                              otherwise the slide namespace.
  +     *
  +     * @return     the <code>&lt;privilege&gt;</code> element.
  +     */
  +    private Element createPrivilege(String privilegeName, boolean useDavNamespace) {
  +        Element privilege = new Element(E_PRIVILEGE, davNamespace);
  +        Namespace namespace = davNamespace;
  +        if ( ! useDavNamespace ) {
  +            namespace = slideNamespace;
  +        }
  +        Element privilegeNameElement = new Element(privilegeName, namespace);
  +        privilege.addContent(privilegeNameElement);
  +        return privilege;
  +    }
  +    
  +    /**
  +     * Creates a <code>&lt;description&gt;</code> element with the given
  +     * <code>text</code>.
  +     *
  +     * @param      text  the text of the <code>&lt;description&gt;</code> element.
  +     *
  +     * @return     the <code>&lt;description&gt;</code> element.
  +     */
  +    private Element createDescription(String text) {
  +        Element description = new Element(E_DESCRIPTION, davNamespace);
  +        description.setText(text);
  +        return description;
  +    }
  +    
  +    /**
  +     * Returns an XMLValue containing the value of the
  +     * <code>&lt;current-user-privilege-set&gt;</code> property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;current-user-privilege-set&gt;</code> 
property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeCurrentuserPrivilegeSet(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();
  +        Security security = nsaToken.getSecurityHelper();
  +        Structure structure = nsaToken.getStructureHelper();
  +        SubjectNode principalNode = null;
  +        ObjectNode object =  structure.retrieve(sToken, 
revisionDescriptors.getUri());
  +        
  +        try {
  +            principalNode = (SubjectNode) security.getPrincipal(sToken);
  +        } catch (SlideException e) {
  +            return xmlValue;
  +        } catch (ClassCastException e) {
  +            return xmlValue;
  +        }
  +        
  +        try {
  +            
  +            boolean readObject =
  +                security.hasPermission(object, principalNode,
  +                                       config.getReadObjectAction());
  +            boolean createObject =
  +                security.hasPermission(object, principalNode,
  +                                       config.getCreateObjectAction());
  +            boolean removeObject =
  +                security.hasPermission(object, principalNode,
  +                                       config.getRemoveObjectAction());
  +            boolean grantPermission =
  +                security.hasPermission(object, principalNode,
  +                                       config.getGrantPermissionAction());
  +            boolean revokePermission =
  +                security.hasPermission(object, principalNode,
  +                                       config.getRevokePermissionAction());
  +            boolean readPermissions =
  +                security.hasPermission(object, principalNode,
  +                                       config.getReadPermissionsAction());
  +            boolean lockObject =
  +                security.hasPermission(object, principalNode,
  +                                       config.getLockObjectAction());
  +            boolean killLock =
  +                security.hasPermission(object, principalNode,
  +                                       config.getKillLockAction());
  +            boolean readLocks =
  +                security.hasPermission(object, principalNode,
  +                                       config.getReadLocksAction());
  +            boolean readRevisionMetadata =
  +                security.hasPermission(object, principalNode,
  +                                       config.getReadRevisionMetadataAction());
  +            boolean createRevisionMetadata = security.hasPermission
  +                (object, principalNode,
  +                 config.getCreateRevisionMetadataAction());
  +            boolean modifyRevisionMetadata = security.hasPermission
  +                (object, principalNode,
  +                 config.getModifyRevisionMetadataAction());
  +            boolean removeRevisionMetadata = security.hasPermission
  +                (object, principalNode,
  +                 config.getRemoveRevisionMetadataAction());
  +            boolean readRevisionContent =
  +                security.hasPermission(object, principalNode,
  +                                       config.getReadRevisionContentAction());
  +            boolean createRevisionContent = security.hasPermission
  +                (object, principalNode,
  +                 config.getCreateRevisionContentAction());
  +            boolean modifyRevisionContent = security.hasPermission
  +                (object, principalNode,
  +                 config.getModifyRevisionContentAction());
  +            boolean removeRevisionContent = security.hasPermission
  +                (object, principalNode,
  +                 config.getRemoveRevisionContentAction());
  +            
  +            boolean canRead = readObject && readRevisionMetadata
  +                && readRevisionContent;
  +            boolean canWrite = createObject && removeObject && lockObject
  +                && readLocks && createRevisionMetadata
  +                && modifyRevisionMetadata && removeRevisionMetadata
  +                && createRevisionContent && modifyRevisionContent
  +                && removeRevisionContent;
  +            boolean canReadAcl = readPermissions;
  +            boolean canWriteAcl = grantPermission && revokePermission;
  +            boolean canAll = canRead && canWrite && canReadAcl && canWriteAcl
  +                && killLock;
  +            
  +            if (canRead) {
  +                xmlValue.add(createPrivilege(E_READ));
  +            }
  +            if (canWrite) {
  +                xmlValue.add(createPrivilege(E_WRITE));
  +            }
  +            if (canReadAcl) {
  +                xmlValue.add(createPrivilege(E_READ_ACL));
  +            }
  +            if (canWriteAcl) {
  +                xmlValue.add(createPrivilege(E_WRITE_ACL));
  +            }
  +            if (canAll) {
  +                xmlValue.add(createPrivilege(E_ALL));
  +            }
  +            
  +        } catch (SlideException e) {
  +            return xmlValue;
  +        }
  +        
  +        return xmlValue;
  +    }
  +    
  +    /**
  +     * Returns an XMLValue containing the value of the
  +     * <code>&lt;acl&gt;</code> property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;acl&gt;</code> property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeAcl(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();
  +        Structure structure = nsaToken.getStructureHelper();
  +        ObjectNode object =  structure.retrieve(sToken, 
revisionDescriptors.getUri());
  +        
  +        // check read-acl permission
  +        Security security = nsaToken.getSecurityHelper();
  +        
  +        security.checkCredentials(sToken, object, 
config.getReadPermissionsAction());
  +        
  +        Element acl = new Element(E_ACL, davNamespace);
  +        xmlValue.add(acl);
  +        
  +        // read
  +        String readObjectUri = config.getReadObjectAction().getUri();
  +        String readRevisionMetadataUri =
  +            config.getReadRevisionMetadataAction().getUri();
  +        String readRevisionContentUri =
  +            config.getReadRevisionContentAction().getUri();
  +        
  +        // write
  +        String createObjectUri = config.getCreateObjectAction().getUri();
  +        String removeObjectUri = config.getRemoveObjectAction().getUri();
  +        String lockObjectUri = config.getLockObjectAction().getUri();
  +        String readLocksUri = config.getReadLocksAction().getUri();
  +        String createRevisionMetadataUri =
  +            config.getCreateRevisionMetadataAction().getUri();
  +        String modifyRevisionMetadataUri =
  +            config.getModifyRevisionMetadataAction().getUri();
  +        String removeRevisionMetadataUri =
  +            config.getRemoveRevisionMetadataAction().getUri();
  +        String createRevisionContentUri =
  +            config.getCreateRevisionContentAction().getUri();
  +        String modifyRevisionContentUri =
  +            config.getModifyRevisionContentAction().getUri();
  +        String removeRevisionContentUri =
  +            config.getRemoveRevisionContentAction().getUri();
  +        
  +        // read-acl
  +        String readPermissionsUri = config.getReadPermissionsAction().getUri();
  +        
  +        // write-acl
  +        String grantPermissionUri = config.getGrantPermissionAction().getUri();
  +        String revokePermissionUri =
  +            config.getRevokePermissionAction().getUri();
  +        
  +        ObjectNode current = object;
  +        boolean inheritedPermissions = false;
  +        Vector permissions = new Vector();
  +        
  +        while (current != null) {
  +            
  +            try {
  +                // put all permissions in a list
  +                permissions.clear();
  +                Enumeration aclList = security.enumeratePermissions(sToken, 
current);
  +                while (aclList.hasMoreElements()) {
  +                    
  +                    NodePermission permission = (NodePermission) 
aclList.nextElement();
  +                    
  +                    // if we are processing inheritedPermissions (from parent and 
up)
  +                    // then the permission should be inheritable
  +                    if (inheritedPermissions && !permission.isInheritable()) {
  +                        // continue with next permission
  +                        continue;
  +                    }
  +                    permissions.add(permission);
  +                }
  +                
  +                // start combining and writing the permissions
  +                while (permissions.size()>0) {
  +                    
  +                    NodePermission permission = (NodePermission) permissions.get(0);
  +                    permissions.remove(0);
  +                    
  +                    String principal = permission.getSubjectUri();
  +                    boolean negative = permission.isNegative();
  +                    
  +                    String action    = permission.getActionUri();
  +                    
  +                    // read
  +                    boolean isReadObject           = 
readObjectUri.startsWith(action);
  +                    boolean isReadLocks            = 
readLocksUri.startsWith(action);
  +                    boolean isReadRevisionMetadata = 
readRevisionMetadataUri.startsWith(action);
  +                    boolean isReadRevisionContent  = 
readRevisionContentUri.startsWith(action);
  +                    
  +                    // write
  +                    boolean isCreateObject           = 
createObjectUri.startsWith(action);
  +                    boolean isRemoveObject           = 
removeObjectUri.startsWith(action);
  +                    boolean isLockObject             = 
lockObjectUri.startsWith(action);
  +                    boolean isCreateRevisionMetadata = 
createRevisionMetadataUri.startsWith(action);
  +                    boolean isModifyRevisionMetadata = 
modifyRevisionMetadataUri.startsWith(action);
  +                    boolean isRemoveRevisionMetadata = 
removeRevisionMetadataUri.startsWith(action);
  +                    boolean isCreateRevisionContent  = 
createRevisionContentUri.startsWith(action);
  +                    boolean isModifyRevisionContent  = 
modifyRevisionContentUri.startsWith(action);
  +                    boolean isRemoveRevisionContent  = 
removeRevisionContentUri.startsWith(action);
  +                    
  +                    //read-acl
  +                    boolean isReadPermissions = 
readPermissionsUri.startsWith(action);
  +                    
  +                    // write-acl
  +                    boolean isGrantPermission  = 
grantPermissionUri.startsWith(action);
  +                    boolean isRevokePermission = 
revokePermissionUri.startsWith(action);
  +                    
  +                    // check the other permissions to combine them
  +                    // (if they are for the same principal/negative)
  +                    for (int i=0; i<permissions.size() ; i++)
  +                    {
  +                        NodePermission otherPermission = (NodePermission) 
permissions.get(i);
  +                        if (principal.equals(otherPermission.getSubjectUri()) && 
(negative==otherPermission.isNegative()))
  +                        {
  +                            permissions.remove(i);
  +                            i--; // because we removed the current one
  +                            
  +                            action    = otherPermission.getActionUri();
  +                            
  +                            // read
  +                            isReadObject           |= 
readObjectUri.startsWith(action);
  +                            isReadLocks            |= 
readLocksUri.startsWith(action);
  +                            isReadRevisionMetadata |= 
readRevisionMetadataUri.startsWith(action);
  +                            isReadRevisionContent  |= 
readRevisionContentUri.startsWith(action);
  +                            
  +                            // write
  +                            isCreateObject           |= 
createObjectUri.startsWith(action);
  +                            isRemoveObject           |= 
removeObjectUri.startsWith(action);
  +                            isLockObject             |= 
lockObjectUri.startsWith(action);
  +                            isCreateRevisionMetadata |= 
createRevisionMetadataUri.startsWith(action);
  +                            isModifyRevisionMetadata |= 
modifyRevisionMetadataUri.startsWith(action);
  +                            isRemoveRevisionMetadata |= 
removeRevisionMetadataUri.startsWith(action);
  +                            isCreateRevisionContent  |= 
createRevisionContentUri.startsWith(action);
  +                            isModifyRevisionContent  |= 
modifyRevisionContentUri.startsWith(action);
  +                            isRemoveRevisionContent  |= 
removeRevisionContentUri.startsWith(action);
  +                            
  +                            //read-acl
  +                            isReadPermissions |= 
readPermissionsUri.startsWith(action);
  +                            
  +                            // write-acl
  +                            isGrantPermission  |= 
grantPermissionUri.startsWith(action);
  +                            isRevokePermission |= 
revokePermissionUri.startsWith(action);
  +                        }
  +                    }
  +                    
  +                    // WebDAV privileges
  +                    boolean isRead = isReadObject && isReadLocks &&
  +                        isReadRevisionMetadata && isReadRevisionContent;
  +                    
  +                    boolean isWrite = isCreateObject && isRemoveObject && 
isLockObject &&
  +                        isCreateRevisionMetadata  && isModifyRevisionMetadata &&
  +                        isRemoveRevisionMetadata &&
  +                        isCreateRevisionContent && isModifyRevisionContent &&
  +                        isRemoveRevisionContent;
  +                    
  +                    boolean isReadAcl = isReadPermissions;
  +                    
  +                    boolean isWriteAcl = isGrantPermission && isRevokePermission;
  +                    
  +                    boolean isAll = isRead && isWrite && isReadAcl && isWriteAcl;
  +                    
  +                    
  +                    // start generating XML
  +                    Element ace = new Element(E_ACE, davNamespace);
  +                    acl.addContent(ace);
  +                    
  +                    ace.addContent(createPrincipal(principal, contextPath));
  +                    
  +                    Element permissionElement = null;
  +                    if (permission.isNegative()) {
  +                        permissionElement = new Element(E_DENY, davNamespace);
  +                    } else {
  +                        permissionElement = new Element(E_GRANT, davNamespace);
  +                    }
  +                    ace.addContent(permissionElement);
  +                    
  +                    if (isAll) {
  +                        permissionElement.addContent(createPrivilege(E_ALL, true));
  +                    } else {
  +                        if (isRead) {
  +                            permissionElement.addContent(createPrivilege(E_READ, 
true));
  +                        } else {
  +                            if (isReadObject)
  +                                
permissionElement.addContent(createPrivilege(E_READ_OBJECT, false));
  +                            if (isReadLocks)
  +                                
permissionElement.addContent(createPrivilege(E_READ_LOCKS, false));
  +                            if (isReadRevisionMetadata)
  +                                
permissionElement.addContent(createPrivilege(E_READ_REVISION_METADATA, false));
  +                            if (isReadRevisionContent)
  +                                
permissionElement.addContent(createPrivilege(E_READ_REVISION_CONTENT, false));
  +                        }
  +                        if (isWrite) {
  +                            permissionElement.addContent(createPrivilege(E_WRITE, 
true));
  +                        } else {
  +                            if (isCreateObject)
  +                                
permissionElement.addContent(createPrivilege(E_CREATE_OBJECT, false));
  +                            if (isRemoveObject)
  +                                
permissionElement.addContent(createPrivilege(E_REMOVE_OBJECT, false));
  +                            if (isLockObject)
  +                                
permissionElement.addContent(createPrivilege(E_LOCK_OBJECT, false));
  +                            if (isCreateRevisionMetadata)
  +                                
permissionElement.addContent(createPrivilege(E_CREATE_REVISION_METADATA, false));
  +                            if (isModifyRevisionMetadata)
  +                                
permissionElement.addContent(createPrivilege(E_MODIFY_REVISION_METADATA, false));
  +                            if (isRemoveRevisionMetadata)
  +                                
permissionElement.addContent(createPrivilege(E_REMOVE_REVISION_METADATA, false));
  +                            if (isCreateRevisionContent)
  +                                
permissionElement.addContent(createPrivilege(E_CREATE_REVISION_CONTENT, false));
  +                            if (isModifyRevisionContent)
  +                                
permissionElement.addContent(createPrivilege(E_MODIFY_REVISION_CONTENT, false));
  +                            if (isRemoveRevisionContent)
  +                                
permissionElement.addContent(createPrivilege(E_REMOVE_REVISION_CONTENT, false));
  +                        }
  +                        if (isReadAcl) {
  +                            
permissionElement.addContent(createPrivilege(E_READ_ACL, true));
  +                        }
  +                        if (isWriteAcl) {
  +                            
permissionElement.addContent(createPrivilege(E_WRITE_ACL, true));
  +                        } else {
  +                            if (isGrantPermission)
  +                                
permissionElement.addContent(createPrivilege(E_GRANT_PERMISSION, false));
  +                            if (isRevokePermission)
  +                                
permissionElement.addContent(createPrivilege(E_REVOKE_PERMISSION, false));
  +                        }
  +                    }
  +                    
  +                    
  +                    if (inheritedPermissions) {
  +                        ace.addContent(new Element(E_PROTECTED, davNamespace));
  +                        Element inherited = new Element(E_INHERITED, davNamespace);
  +                        ace.addContent(inherited);
  +                        Element href = new Element(E_HREF, davNamespace);
  +                        inherited.addContent(href);
  +                        href.setText(getAbsoluteURL(null, contextPath, 
current.getUri()));
  +                    }
  +                    
  +                }
  +                
  +            } catch (SlideException e) {
  +            }
  +            
  +            inheritedPermissions = true;
  +            
  +            try {
  +                current = structure.getParent(sToken, current);
  +            } catch (SlideException e) {
  +                break;
  +            }
  +            
  +        }
  +        
  +        return xmlValue;
  +    }
  +    
  +    /**
  +     * Creates a <code>&lt;principal&gt;</code> element containing an
  +     * either and <code>&lt;self&gt;</code>, <code>&lt;all&gt;</code> or
  +     * <code>&lt;href&gt;</code> element.
  +     *
  +     * @param      principalName  the name of the principal.
  +     * @param      contextPath    the context path.
  +     *
  +     * @return     the <code>&lt;principal&gt;</code> element.
  +     */
  +    private Element createPrincipal(String principalName, String contextPath) {
  +        
  +        Element principal = new Element(E_PRINCIPAL, davNamespace);
  +        
  +        // FIXME: Apparently, there are or will be some other cases, but it
  +        // isn't very clear in the spec
  +        if (principalName.equals("~")) {
  +            principal.addContent(new Element(E_SELF, davNamespace));
  +        } else if (principalName.equals("nobody")) {
  +            principal.addContent(new Element(E_ALL, davNamespace));
  +        } else {
  +            Element href = new Element(E_HREF, davNamespace);
  +            href.setText(getAbsoluteURL(null, contextPath, principalName));
  +            principal.addContent(href);
  +        }
  +        
  +        return principal;
  +    }
  +    
  +    /**
  +     * Returns an XMLValue containing the value of the
  +     * <code>&lt;acl-semantics&gt;</code> property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;acl-semantics&gt;</code> property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeAclSemantics(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
  +        
  +        XMLValue xmlValue = new XMLValue();
  +        
  +        Element aceCombination = new Element(E_ACE_COMBINATION, davNamespace);
  +        xmlValue.add(aceCombination);
  +        Element allGrantBeforeDeny = new Element(E_ALL_GRANT_BEFORE_DENY, 
davNamespace);
  +        aceCombination.addContent(allGrantBeforeDeny);
  +        
  +        Element requiredPrincipal = new Element(E_REQUIRED_PRINCIPAL, davNamespace);
  +        xmlValue.add(requiredPrincipal);
  +        Element all = new Element(E_ALL, davNamespace);
  +        requiredPrincipal.addContent(all);
  +        
  +        return xmlValue;
  +    }
  +    
  +    
  +    /**
  +     * Returns an XMLValue containing the value of the
  +     * <code>&lt;principal-collection-set&gt;</code> property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;principal-collection-set&gt;</code> 
property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @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 = new Element(E_HREF, davNamespace);
  +        href.setText(getAbsoluteURL(null, contextPath, config.getUsersPath()));
  +        xmlValue.add(href);
  +        
  +        return xmlValue;
  +    }
  +    
  +    
  +    /**
  +     * Returns an XMLValue containing the value of the
  +     * <code>&lt;owner&gt;</code> property.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the resource.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the resource.
  +     * @param    contextPath         the context path of the 
NodeRevisionDescriptors' uri.
  +     *                               The concatenation of <code>serverURL</code>/
  +     *                               
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
  +     *                               gives the absolute URL of the resource.
  +     * @param    serverURL           the URL of the server (e.g. 
<code>http://www.abc.com</code>).
  +     *
  +     * @return   the value of the <code>&lt;owner&gt;</code> property.
  +     *
  +     * @throws   ObjectLockedException
  +     * @throws   RevisionDescriptorNotFoundException
  +     * @throws   ServiceAccessException
  +     * @throws   LinkedObjectNotFoundException
  +     * @throws   AccessDeniedException
  +     * @throws   ObjectNotFoundException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeOwner(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
  +        
  +        XMLValue xmlValue = new XMLValue();
  +        
  +        NodeProperty ownerProperty = revisionDescriptor.getProperty(P_OWNER,
  +                                                                    
NodeProperty.DEFAULT_NAMESPACE);
  +        String ownerHref;
  +        NamespaceConfig config = nsaToken.getNamespaceConfig();
  +        if ((ownerProperty != null) && (ownerProperty.getValue()!=null) &&
  +                (!"".equals(ownerProperty.getValue().toString()))) {
  +            ownerHref = config.toString() + config.getUsersPath() + "/" + 
ownerProperty.getValue().toString();
  +        }
  +        else {
  +            ownerHref =  config.toString() + config.getUsersPath() + "/" + 
config.getGuestPath();
  +        }
  +        Element href = new Element(E_HREF, davNamespace);
  +        href.setText(ownerHref);
  +        xmlValue.add(href);
  +        
  +        return xmlValue;
  +    }
  +    
       
       /**
        * Returns the concatenation of <code>serverURL</code>, <code>contextPath</code>
  
  
  

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

Reply via email to