pnever      2003/08/18 00:01:27

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        PropertyHelper.java
  Log:
  Prepare for binding and made DAV:workspace computed
  
  Revision  Changes    Path
  1.49      +417 -282  
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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- PropertyHelper.java       8 Aug 2003 15:27:24 -0000       1.48
  +++ PropertyHelper.java       18 Aug 2003 07:01:27 -0000      1.49
  @@ -63,19 +63,34 @@
   
   package org.apache.slide.webdav.util;
   
  -import java.util.*;
  -import org.apache.slide.common.*;
  -import org.apache.slide.content.*;
  -import org.apache.slide.webdav.util.resourcekind.*;
  -import org.jdom.*;
  -
   import java.io.IOException;
   import java.io.StringReader;
   import java.security.MessageDigest;
   import java.security.NoSuchAlgorithmException;
   import java.security.Principal;
  +import java.util.ArrayList;
  +import java.util.Collections;
  +import java.util.Date;
  +import java.util.Enumeration;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Set;
  +import java.util.Vector;
   import org.apache.slide.authenticate.CredentialsToken;
  +import org.apache.slide.common.Domain;
  +import org.apache.slide.common.NamespaceAccessToken;
  +import org.apache.slide.common.NamespaceConfig;
  +import org.apache.slide.common.ServiceAccessException;
  +import org.apache.slide.common.SlideException;
  +import org.apache.slide.common.SlideToken;
  +import org.apache.slide.common.SlideTokenWrapper;
  +import org.apache.slide.content.Content;
  +import org.apache.slide.content.NodeProperty;
   import org.apache.slide.content.NodeProperty.NamespaceCache;
  +import org.apache.slide.content.NodeRevisionDescriptor;
  +import org.apache.slide.content.NodeRevisionDescriptors;
  +import org.apache.slide.content.NodeRevisionNumber;
  +import org.apache.slide.content.RevisionDescriptorNotFoundException;
   import org.apache.slide.lock.Lock;
   import org.apache.slide.lock.LockTokenNotFoundException;
   import org.apache.slide.lock.NodeLock;
  @@ -92,9 +107,24 @@
   import org.apache.slide.structure.ObjectNotFoundException;
   import org.apache.slide.structure.Structure;
   import org.apache.slide.structure.SubjectNode;
  +import org.apache.slide.util.Configuration;
   import org.apache.slide.webdav.WebdavServletConfig;
   import org.apache.slide.webdav.method.LockMethod;
  +import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
  +import org.apache.slide.webdav.util.resourcekind.Activity;
  +import org.apache.slide.webdav.util.resourcekind.CheckedInVersionControlled;
  +import org.apache.slide.webdav.util.resourcekind.CheckedOutVersionControlled;
  +import org.apache.slide.webdav.util.resourcekind.DeltavCompliantCollection;
  +import org.apache.slide.webdav.util.resourcekind.ResourceKind;
  +import org.apache.slide.webdav.util.resourcekind.Version;
  +import org.apache.slide.webdav.util.resourcekind.VersionHistory;
  +import org.apache.slide.webdav.util.resourcekind.Workspace;
   import org.apache.util.MD5Encoder;
  +import org.jdom.Attribute;
  +import org.jdom.CDATA;
  +import org.jdom.Document;
  +import org.jdom.Element;
  +import org.jdom.JDOMException;
   import org.jdom.Namespace;
   import org.jdom.input.SAXBuilder;
   
  @@ -106,61 +136,61 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Nevermann</a>
    */
   
  -public class PropertyHelper extends AbstractWebdavHelper implements 
WebdavConstants, DeltavConstants, AclConstants, DaslConstants {
  -
  +public class PropertyHelper extends AbstractWebdavHelper implements 
WebdavConstants, DeltavConstants, AclConstants, DaslConstants, BindConstants {
  +    
       public final static String DEFAULT_AUTO_VERSION =
           Domain.getParameter( I_AUTO_VERSION, I_AUTO_VERSION_DEFAULT );
  -
  +    
       public final static String DEFAULT_CHECKOUT_FORK =
           Domain.getParameter( I_CHECKOUT_FORK, I_CHECKOUT_FORK_DEFAULT );
  -
  +    
       public final static String DEFAULT_CHECKIN_FORK =
           Domain.getParameter( I_CHECKIN_FORK, I_CHECKIN_FORK_DEFAULT );
  -
  +    
       public final static String LOCKDISCOVERY_INCL_PRINCIPAL =
           "lockdiscoveryIncludesPrincipalURL";
  -
  +    
       private final static String USER_COLLECTION = "user_collection";
       
       private boolean lockdiscoveryIncludesPrincipalURL = true;
  -
  +    
       /**
        * The Element returned by [EMAIL PROTECTED] #getCheckoutSetQueryElement
        * getCheckoutSetQueryElement()}.
        */
       protected Element checkoutSetQueryElement = null;
  -
  +    
       /**
        * The &lt;literal&gt; Element used in the basic search query returned by
        * [EMAIL PROTECTED] #getCheckoutSetQueryElement getCheckoutSetQueryElement()}.
        */
       protected Element checkoutSetQueryLiteralElement = null;
  -
  +    
       /**
        * The Element returned by [EMAIL PROTECTED] 
#getWorkspaceCheckoutSetQueryElement
        * getWorkspaceCheckoutSetQueryElement()}.
        */
       protected Element workspaceCheckoutSetQueryElement = null;
  -
  +    
       /**
        * The &lt;href&gt; Element used in the basic search query returned by
        * [EMAIL PROTECTED] #getWorkspaceCheckoutSetQueryElement 
getWorkspaceCheckoutSetQueryElement()}.
        */
       protected Element workspaceCheckoutSetQueryHrefElement = null;
  -
  +    
       private WebdavServletConfig sConf = null;
  -
  -
  -
  +    
  +    
  +    
       /**
        * Factory method.
        * @deprecated
        */
       public static PropertyHelper
  -    getPropertyHelper( SlideToken sToken, NamespaceAccessToken nsaToken) {
  +        getPropertyHelper( SlideToken sToken, NamespaceAccessToken nsaToken) {
           return new PropertyHelper( sToken, nsaToken, null );
       }
  -
  +    
       /**
        * Factory method.
        */
  @@ -168,8 +198,8 @@
           getPropertyHelper( SlideToken sToken, NamespaceAccessToken nsaToken, 
WebdavServletConfig sConf ) {
           return new PropertyHelper( sToken, nsaToken, sConf );
       }
  -
  -
  +    
  +    
       /**
        * Protected contructor
        */
  @@ -180,7 +210,7 @@
               lockdiscoveryIncludesPrincipalURL =
                   
!("false".equalsIgnoreCase(sConf.getInitParameter(LOCKDISCOVERY_INCL_PRINCIPAL)));
       }
  -
  +    
       /**
        * Create initial default properties to be stored for the specified
        * resource kind.
  @@ -189,10 +219,10 @@
        * @return a list of initial non-transient properties (empty list if none)
        */
       public List createInitialProperties( ResourceKind resourceKind ) {
  -
  +        
           Set sp = resourceKind.getSupportedLiveProperties();
           List result = null;
  -
  +        
           if( sp == null )
               result = Collections.EMPTY_LIST;
           else {
  @@ -208,24 +238,24 @@
           }
           return result;
       }
  -
  +    
       /**
        * Create a default value for the specified property name and resource
        * kind
        */
       Object createDefaultValue( String propName, ResourceKind resourceKind ) {
  -
  +        
           String result = "";
  -
  +        
           if( P_RESOURCETYPE.equals(propName) ) {
               StringBuffer rtvv = new StringBuffer();
               try {
                   if( resourceKind instanceof VersionHistory ) {
  -                rtvv.append(
  +                    rtvv.append(
                           xmlOut.outputString(new Element(E_VERSION_HISTORY, 
NamespaceCache.DEFAULT_NAMESPACE)) );
  -                rtvv.append(
  +                    rtvv.append(
                           xmlOut.outputString(new Element(E_COLLECTION, 
NamespaceCache.DEFAULT_NAMESPACE)) );
  -            }
  +                }
                   if( resourceKind instanceof DeltavCompliantCollection ) {
                       rtvv.append(
                           xmlOut.outputString(new Element(E_COLLECTION, 
NamespaceCache.DEFAULT_NAMESPACE)) );
  @@ -288,51 +318,51 @@
               result = srsv.toString();
           }
           else if( P_AUTO_VERSION.equals(propName) ) {
  -
  +            
               XMLValue xmlValue = new XMLValue();
  -
  +            
               if (DEFAULT_AUTO_VERSION.length() > 0) {
                   xmlValue.add(new Element(DEFAULT_AUTO_VERSION, 
NamespaceCache.DEFAULT_NAMESPACE));
               }
  -
  +            
               if( ! resourceKind.isSupportedPropertyValue(P_AUTO_VERSION, xmlValue) ) 
{
                   Domain.warn( "Auto-version not configured properly; using "
  -                             +E_CHECKOUT_CHECKIN );
  +                                +E_CHECKOUT_CHECKIN );
                   xmlValue = new XMLValue(new Element(E_CHECKOUT_CHECKIN, 
NamespaceCache.DEFAULT_NAMESPACE));
               }
  -
  +            
               result = xmlValue.toString();
           }
           else if( P_CHECKOUT_FORK.equals(propName) ) {
  -
  +            
               XMLValue xmlValue = new XMLValue();
  -
  +            
               if (DEFAULT_CHECKOUT_FORK.length() > 0) {
                   xmlValue.add(new Element(DEFAULT_CHECKOUT_FORK, 
NamespaceCache.DEFAULT_NAMESPACE));
               }
  -
  +            
               if( ! resourceKind.isSupportedPropertyValue(P_CHECKOUT_FORK, xmlValue) 
) {
                   Domain.warn( "Checkout-fork not configured properly; using "
  -                             +E_FORBIDDEN );
  +                                +E_FORBIDDEN );
                   xmlValue = new XMLValue(new Element(E_FORBIDDEN, 
NamespaceCache.DEFAULT_NAMESPACE));
               }
  -
  +            
               result = xmlValue.toString();
           }
           else if( P_CHECKIN_FORK.equals(propName) ) {
  -
  +            
               XMLValue xmlValue = new XMLValue();
  -
  +            
               if (DEFAULT_CHECKIN_FORK.length() > 0) {
                   xmlValue.add(new Element(DEFAULT_CHECKIN_FORK, 
NamespaceCache.DEFAULT_NAMESPACE));
               }
  -
  +            
               if( ! resourceKind.isSupportedPropertyValue(P_CHECKIN_FORK, xmlValue) ) 
{
                   Domain.warn( "Checkin-fork not configured properly; using "
  -                             +E_FORBIDDEN );
  +                                +E_FORBIDDEN );
                   xmlValue = new XMLValue(new Element(E_FORBIDDEN, 
NamespaceCache.DEFAULT_NAMESPACE));
               }
  -
  +            
               result = xmlValue.toString();
           }
           else if( P_GETCONTENTLANGUAGE.equals(propName) ) {
  @@ -348,10 +378,10 @@
                   }
               }
           }
  -
  +        
           return result;
       }
  -
  +    
       /**
        * Create CDATA value.
        */
  @@ -362,13 +392,13 @@
           b.append( "![CDATA[" ).append( text ).append( "]]" );
           return b.toString();
       }
  -
  +    
       /**
        * Create href value.
        */
       public Object createHrefValue( String uri ) {
           String result = "";
  -
  +        
           Element href = new Element( E_HREF, NamespaceCache.DEFAULT_NAMESPACE );
           href.addContent( uri );
           try {
  @@ -377,10 +407,10 @@
           catch( Exception x ) {
               x.printStackTrace();
           }
  -
  +        
           return result;
       }
  -
  +    
       /**
        * Create href set value.
        */
  @@ -391,16 +421,16 @@
               b.append( createHrefValue((String)i.next()) );
           return b.toString();
       }
  -
  +    
       /**
        * Create href set value.
        */
       public Object createHrefSetValue( String rootElement, List uriList ) {
           String result = "";
  -
  +        
           Element root = new Element( rootElement, NamespaceCache.DEFAULT_NAMESPACE );
           Iterator i = uriList.iterator();
  -
  +        
           while( i.hasNext() ) {
               Element href = new Element( E_HREF, NamespaceCache.DEFAULT_NAMESPACE );
               href.addContent( (String)i.next() );
  @@ -412,10 +442,10 @@
           catch( Exception x ) {
               x.printStackTrace();
           }
  -
  +        
           return result;
       }
  -
  +    
       /**
        * Parse an XML-Valued property value.
        */
  @@ -423,7 +453,7 @@
           Document d = xmlBuilder.build( new StringReader(propValue) );
           return d.getRootElement();
       }
  -
  +    
       /**
        * Returns the property of the resource described by
        * the resourcePath.
  @@ -439,7 +469,7 @@
       public NodeProperty getProperty(String propertyName, String resourcePath) 
throws SlideException, JDOMException {
           return getProperty(propertyName, resourcePath, null, null);
       }
  -
  +    
       /**
        * Returns the property of the resource described by
        * the resourcePath.
  @@ -457,13 +487,13 @@
        * @throws   JDOMException
        */
       public NodeProperty getProperty(String propertyName, String resourcePath, 
String contextPath, String serverURL) throws SlideException, JDOMException {
  -
  +        
           UriHandler uriHandler = UriHandler.getUriHandler(resourcePath);
           String uri = null;
           NodeRevisionDescriptors revisionDescriptors = null;
           NodeRevisionDescriptor revisionDescriptor = null;
           Content contentHelper = nsaToken.getContentHelper();
  -
  +        
           if (uriHandler.isVersionUri()) {
               uri = uriHandler.getAssociatedHistoryUri();
               NodeRevisionNumber revisionNumber = new 
NodeRevisionNumber(uriHandler.getVersionName());
  @@ -483,7 +513,7 @@
           }
           return getProperty(propertyName, revisionDescriptors, revisionDescriptor, 
contextPath, serverURL);
       }
  -
  +    
       /**
        * Returns the property of the resource described by
        * the resourcePath.
  @@ -500,7 +530,7 @@
       public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws SlideException, 
JDOMException {
           return getProperty(propertyName, revisionDescriptors, revisionDescriptor, 
null, null);
       }
  -
  +    
       /**
        * Returns the property of the resource described by
        * the resourcePath.
  @@ -520,7 +550,7 @@
        * @throws   JDOMException
        */
       public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws SlideException, JDOMException {
  -
  +        
           NodeProperty property = revisionDescriptor.getProperty( propertyName );
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           if (resourceKind.isSupportedLiveProperty(propertyName)) {
  @@ -528,10 +558,10 @@
                   property = computeProperty(propertyName, revisionDescriptors, 
revisionDescriptor, contextPath, serverURL);
               }
           }
  -
  +        
           return property;
       }
  -
  +    
       /**
        * Returns the computed property of the resource.
        *
  @@ -550,7 +580,7 @@
        * @throws   JDOMException
        */
       public NodeProperty computeProperty(String propertyName, 
NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor 
revisionDescriptor, String contextPath, String serverURL) throws SlideException, 
JDOMException {
  -
  +        
           NodeProperty property = null;
           if (P_SUCCESSOR_SET.equals(propertyName)) {
               property = new NodeProperty(propertyName, 
computeSuccessorSet(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
  @@ -576,7 +606,19 @@
           else if (P_WORKSPACE_CHECKOUT_SET.equals(propertyName)) {
               property = new NodeProperty(propertyName, 
computeWorkspaceCheckoutSet(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
           }
  -
  +        else if (P_WORKSPACE.equals(propertyName)) {
  +            XMLValue ws = null;
  +            if (Configuration.useBinding(nsaToken.getUri(sToken, 
revisionDescriptors.getUri()).getStore())) {
  +                ws = computeWorkspace(revisionDescriptors, revisionDescriptor, 
contextPath, serverURL);
  +            }
  +            else {
  +                ws = computeWorkspaceNoBinding(revisionDescriptors, 
revisionDescriptor, contextPath, serverURL);
  +            }
  +            if (ws != null) {
  +                property = new NodeProperty(propertyName, ws);
  +            }
  +        }
  +            
           else if (P_LOCKDISCOVERY.equals(propertyName)) {
               property = new NodeProperty(propertyName, 
computeLockDiscovery(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
           }
  @@ -601,10 +643,10 @@
           else if (P_OWNER.equals(propertyName)) {
               property = new NodeProperty(propertyName, 
computeOwner(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
           }
  -
  +        
           return property;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the <code>&lt;href&gt;</code> elements
        * describing the successors of the resource.
  @@ -627,13 +669,13 @@
        * @throws   ObjectNotFoundException
        */
       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, NamespaceCache.DEFAULT_NAMESPACE);
           NodeRevisionDescriptor successorRevisionDescriptor = null;
           NodeRevisionNumber successorRevisionNumber = null;
           Enumeration successorEnum = 
revisionDescriptors.getSuccessors(revisionDescriptor.getRevisionNumber());
  -
  +        
           if (successorEnum != null) {
               while (successorEnum.hasMoreElements()) {
                   successorRevisionNumber = 
(NodeRevisionNumber)successorEnum.nextElement();
  @@ -649,7 +691,7 @@
           }
           return xmlValue;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the <code>&lt;href&gt;</code> element
        * with the history URI of the resource. If the resource is neither a
  @@ -674,7 +716,7 @@
        * @throws   JDOMException
        */
       public XMLValue computeVersionHistory(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, JDOMException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           if (resourceKind instanceof Version) {
  @@ -698,10 +740,10 @@
               element.setText(getAbsoluteURL(serverURL, contextPath, 
uriHandler.getAssociatedHistoryUri()));
               xmlValue.add(element);
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the <code>&lt;href&gt;</code> element
        * with the URI of the root version of the history.
  @@ -725,9 +767,9 @@
        * @throws   ObjectNotFoundException
        */
       public XMLValue computeRootVersion(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
  -
  +        
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           if (resourceKind instanceof VersionHistory) {
               Element element = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  @@ -739,10 +781,10 @@
               element.setText(getAbsoluteURL(serverURL, contextPath, 
buffer.toString()));
               xmlValue.add(element);
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the <code>&lt;supported-method&gt;</code>
        * elements with the name (attribute) of the supported methods.
  @@ -772,9 +814,9 @@
        * @throws   ObjectNotFoundException
        */
       public XMLValue computeSupportedMethodSet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
  -
  +        
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           Set supportedMethodNames = resourceKind.getSupportedMethods();
           Iterator iterator = supportedMethodNames.iterator();
  @@ -784,10 +826,10 @@
               supportedMethod.setAttribute(new Attribute(E_NAME, 
(String)iterator.next()));
               xmlValue.add(supportedMethod);
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the 
<code>&lt;supported-live-property&gt;</code>
        * elements containing <code>&lt;prop&gt;</code> which are containing
  @@ -818,9 +860,9 @@
        * @throws   ObjectNotFoundException
        */
       public XMLValue computeSupportedLivePropertySet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
  -
  +        
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           Set supportedLivePropertyNames = resourceKind.getSupportedLiveProperties();
           Iterator iterator = supportedLivePropertyNames.iterator();
  @@ -828,7 +870,7 @@
           Element propElement = null;
           Element propertyElement = null;
           while (iterator.hasNext()) {
  -
  +            
               supportedLivePropertyElement = new Element(E_SUPPORTED_LIVE_PROPERTY, 
NamespaceCache.DEFAULT_NAMESPACE);
               propElement = new Element(E_PROP, NamespaceCache.DEFAULT_NAMESPACE);
               supportedLivePropertyElement.addContent(propElement);
  @@ -836,10 +878,10 @@
               propElement.addContent(propertyElement);
               xmlValue.add(supportedLivePropertyElement);
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the <code>&lt;supported-report&gt;</code>
        * elements containing <code>&lt;report&gt;</code> which are containing
  @@ -870,9 +912,9 @@
        * @throws   ObjectNotFoundException
        */
       public XMLValue computeSupportedReportSet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
  -
  +        
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           Set supportedReportNames = resourceKind.getSupportedReports();
           Iterator iterator = supportedReportNames.iterator();
  @@ -880,7 +922,7 @@
           Element reportElement = null;
           Element propertyElement = null;
           while (iterator.hasNext()) {
  -
  +            
               supportedReportElement = new Element(E_SUPPORTED_REPORT, 
NamespaceCache.DEFAULT_NAMESPACE);
               reportElement = new Element(E_REPORT, NamespaceCache.DEFAULT_NAMESPACE);
               supportedReportElement.addContent(reportElement);
  @@ -888,10 +930,10 @@
               reportElement.addContent(propertyElement);
               xmlValue.add(supportedReportElement);
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns an XMLValue containing <code>&lt;href&gt;</code> elements
        * with the URI of the VCRs that have a <code>&lt;checked-out&gt;</code>
  @@ -914,7 +956,7 @@
       public XMLValue computeCheckoutSet(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor) throws SlideException, JDOMException {
           return computeCheckoutSet(revisionDescriptors, revisionDescriptor, null, 
null);
       }
  -
  +    
       /**
        * Returns an XMLValue containing <code>&lt;href&gt;</code> elements
        * with the URI of the VCRs that have a <code>&lt;checked-out&gt;</code>
  @@ -935,20 +977,20 @@
        * @throws   JDOMException
        */
       public XMLValue computeCheckoutSet(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
throws SlideException, JDOMException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
  -
  +        
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           if (resourceKind instanceof Version) {
  -
  +            
               String resourcePath = VersioningHelper.getUri(nsaToken,
                                                             new 
SlideTokenWrapper(sToken, false),
                                                             
nsaToken.getContentHelper(),
                                                             revisionDescriptors,
                                                             revisionDescriptor);
  -
  +            
               Element basicSearch = getCheckoutSetQueryElement(resourcePath);
  -
  +            
               String grammarNamespace = basicSearch.getNamespaceURI();
               Search searchHelper = nsaToken.getSearchHelper();
               SearchQuery searchQuery = 
searchHelper.createSearchQuery(grammarNamespace,
  @@ -956,7 +998,7 @@
                                                                        new 
SlideTokenWrapper(sToken, false),
                                                                        
Integer.MAX_VALUE,
                                                                        contextPath);
  -
  +            
               SearchQueryResult queryResult = searchHelper.search(new 
SlideTokenWrapper(sToken,false), searchQuery);
               Iterator queryResultIterator = queryResult.iterator();
               RequestedResource requestedResource = null;
  @@ -968,10 +1010,10 @@
                   xmlValue.add(href);
               }
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns the query document used to search all resources that have
        * a &lt;checked-out&gt; property with a &lt;href&gt; value containing
  @@ -982,18 +1024,18 @@
        * @return     the query document.
        */
       protected Element getCheckoutSetQueryElement(String resourcePath) throws 
SlideException {
  -
  +        
           if (checkoutSetQueryElement == null) {
  -
  +            
               checkoutSetQueryElement = new Element(DaslConstants.E_BASICSEARCH, 
NamespaceCache.DEFAULT_NAMESPACE);
  -
  +            
               Element select = new Element(DaslConstants.E_SELECT, 
NamespaceCache.DEFAULT_NAMESPACE);
               checkoutSetQueryElement.addContent(select);
               Element prop = new Element(E_PROP, NamespaceCache.DEFAULT_NAMESPACE);
               select.addContent(prop);
               Element checkedOut = new Element(P_CHECKED_OUT, 
NamespaceCache.DEFAULT_NAMESPACE);
               prop.addContent(checkedOut);
  -
  +            
               Element from = new Element(DaslConstants.E_FROM, 
NamespaceCache.DEFAULT_NAMESPACE);
               checkoutSetQueryElement.addContent(from);
               Element scope = new Element(DaslConstants.E_SCOPE, 
NamespaceCache.DEFAULT_NAMESPACE);
  @@ -1005,7 +1047,7 @@
               while (excludeIterator.hasNext()) {
                   scope.addContent((Element)excludeIterator.next());
               }
  -
  +            
               Element where = new Element(DaslConstants.E_WHERE, 
NamespaceCache.DEFAULT_NAMESPACE);
               checkoutSetQueryElement.addContent(where);
               Element propcontains = new Element(DaslConstants.E_PROPCONTAINS, 
NamespaceCache.SLIDE_NAMESPACE);
  @@ -1015,10 +1057,10 @@
               propcontains.addContent(checkoutSetQueryLiteralElement);
           }
           checkoutSetQueryLiteralElement.setText(resourcePath);
  -
  +        
           return checkoutSetQueryElement;
       }
  -
  +    
       /**
        ** Returns a List of <code>&lt;exclude&gt;</code> elements containing the
        ** paths to exclude from the search since they does not contain
  @@ -1030,24 +1072,113 @@
        ** @return     a List of <code>&lt;exclude&gt;</code> elements.
        **/
       public List getNonVcrPathExcludeList() {
  -
  +        
           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);
  -
  +        
           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);
           }
  -
  +        
           return excludeList;
       }
  -
  +    
  +    /**
  +     * Returns an XMLValue containing <code>&lt;href&gt;</code> elements
  +     * with the URI of the VCRs in the workspace identified the given
  +     * NodeRevisionDescriptor(s) that have a <code>&lt;checked-out&gt;</code>.
  +     * If the resource is not a Workspace, the returned XMLValue is empty.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the Workspace.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the Workspace.
  +     * @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;workspace-checkout-set&gt;</code> 
property.
  +     *
  +     * @throws   SlideException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeWorkspaceNoBinding(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws SlideException, JDOMException {
  +        XMLValue result = null;
  +        UriHandler hrUh = UriHandler.getUriHandler(revisionDescriptors, 
revisionDescriptor);
  +        String associatedWsUri = hrUh.getAssociatedWorkspaceUri();
  +        if (associatedWsUri != null) {
  +            result = new XMLValue();
  +            Element hrElm = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  +            hrElm.setText(associatedWsUri);
  +            result.add(hrElm);
  +        }
  +        return result;
  +    }
  +    
  +    /**
  +     * Returns an XMLValue containing <code>&lt;href&gt;</code> elements
  +     * with the URI of the VCRs in the workspace identified the given
  +     * NodeRevisionDescriptor(s) that have a <code>&lt;checked-out&gt;</code>.
  +     * If the resource is not a Workspace, the returned XMLValue is empty.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the Workspace.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the Workspace.
  +     * @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;workspace-checkout-set&gt;</code> 
property.
  +     *
  +     * @throws   SlideException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeWorkspace(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
throws SlideException, JDOMException {
  +        XMLValue result = null;
  +        NodeProperty psProp = revisionDescriptor.getProperty(P_PARENT_SET);
  +        List psUris = new ArrayList();
  +        XMLValue xv = new XMLValue(String.valueOf(psProp.getValue()));
  +        Iterator i = xv.getList().iterator();
  +        while (i.hasNext()) {
  +            Element pElm = (Element)i.next();
  +            UriHandler hrUh = new UriHandler(pElm.getChild(E_HREF, 
NamespaceCache.DEFAULT_NAMESPACE).getText());
  +            if (hrUh.getAssociatedWorkspaceUri() != null) {
  +                result = new XMLValue();
  +                Element hrElm = new Element(E_HREF, 
NamespaceCache.DEFAULT_NAMESPACE);
  +                hrElm.setText(hrUh.getAssociatedWorkspaceUri());
  +                result.add(hrElm);
  +                break;
  +            }
  +            else if (!hrUh.isRootUri()) {
  +                psUris.add(hrUh);
  +            }
  +        }
  +        
  +        if (result == null) {
  +            i = psUris.iterator();
  +            while (i.hasNext()) {
  +                NodeRevisionDescriptors nrds =
  +                    nsaToken.getContentHelper().retrieve(sToken, 
((UriHandler)i.next()).getUri());
  +                NodeRevisionDescriptor nrd =
  +                    nsaToken.getContentHelper().retrieve(sToken, nrds);
  +                result = computeWorkspace(nrds, nrd, contextPath, serverURL);
  +                if (result != null) {
  +                    break;
  +                }
  +            }
  +        }
  +        
  +        return result;
  +    }
  +    
       /**
        * Returns an XMLValue containing <code>&lt;href&gt;</code> elements
        * with the URI of the VCRs in the workspace identified the given
  @@ -1068,12 +1199,12 @@
        * @throws   JDOMException
        */
       public XMLValue computeWorkspaceCheckoutSet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws SlideException, JDOMException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
  -
  +        
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(nsaToken, revisionDescriptors, 
revisionDescriptor);
           if (resourceKind instanceof Workspace) {
  -
  +            
               Element basicSearch = 
getWorkspaceCheckoutSetQueryElement(revisionDescriptors.getUri());
               String grammarNamespace = basicSearch.getNamespaceURI();
               Search searchHelper = nsaToken.getSearchHelper();
  @@ -1093,10 +1224,10 @@
                   xmlValue.add(hrefElement);
               }
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns the query document used to search all resources that have
        * a &lt;checked-out&gt; property within the given <code>scopePath</code>.
  @@ -1106,25 +1237,25 @@
        * @return     the query document.
        */
       protected Element getWorkspaceCheckoutSetQueryElement(String scopePath) {
  -
  +        
           if (workspaceCheckoutSetQueryElement == null) {
  -
  +            
               workspaceCheckoutSetQueryElement = new 
Element(DaslConstants.E_BASICSEARCH, NamespaceCache.DEFAULT_NAMESPACE);
  -
  +            
               Element select = new Element(DaslConstants.E_SELECT, 
NamespaceCache.DEFAULT_NAMESPACE);
               workspaceCheckoutSetQueryElement.addContent(select);
               Element prop = new Element(E_PROP, NamespaceCache.DEFAULT_NAMESPACE);
               select.addContent(prop);
               Element checkedOut = new Element(P_CHECKED_OUT, 
NamespaceCache.DEFAULT_NAMESPACE);
               prop.addContent(checkedOut);
  -
  +            
               Element from = new Element(DaslConstants.E_FROM, 
NamespaceCache.DEFAULT_NAMESPACE);
               workspaceCheckoutSetQueryElement.addContent(from);
               Element scope = new Element(DaslConstants.E_SCOPE, 
NamespaceCache.DEFAULT_NAMESPACE);
               from.addContent(scope);
               workspaceCheckoutSetQueryHrefElement = new Element(E_HREF, 
NamespaceCache.DEFAULT_NAMESPACE);
               scope.addContent(workspaceCheckoutSetQueryHrefElement);
  -
  +            
               Element where = new Element(DaslConstants.E_WHERE, 
NamespaceCache.DEFAULT_NAMESPACE);
               workspaceCheckoutSetQueryElement.addContent(where);
               Element isdefined = new Element(DaslConstants.E_ISDEFINED, 
NamespaceCache.DEFAULT_NAMESPACE);
  @@ -1132,10 +1263,10 @@
               isdefined.addContent((Element)prop.clone());
           }
           
workspaceCheckoutSetQueryHrefElement.setText(truncateLeadingSlash(scopePath));
  -
  +        
           return workspaceCheckoutSetQueryElement;
  -        }
  -
  +    }
  +    
       /**
        * Returns an XMLValue containing the value of the 
<code>&lt;lockdiscovery&gt;</code>
        * property.
  @@ -1155,23 +1286,23 @@
        * @throws   ObjectNotFoundException
        */
       public XMLValue computeLockDiscovery(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ServiceAccessException, LinkedObjectNotFoundException, 
ObjectNotFoundException, LockTokenNotFoundException {
  -
  +        
           XMLValue xmlValue = new XMLValue();
           Lock lock = nsaToken.getLockHelper();
           NodeLock objectLockToken = null;
           Enumeration lockTokens = lock.enumerateLocks(new SlideTokenWrapper(sToken, 
false), revisionDescriptors.getUri(), true);
           while (lockTokens.hasMoreElements()) {
  -
  +            
               objectLockToken = (NodeLock) lockTokens.nextElement();
               Element activelock = createActiveLockElement(objectLockToken,serverURL, 
contextPath);
               if (activelock != null) {
                   xmlValue.add(activelock);
               }
           }
  -
  +        
           return xmlValue;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the value of the 
<code>&lt;lockdiscovery&gt;</code>
        * property.
  @@ -1188,16 +1319,16 @@
        *
        */
       public XMLValue computeLockDiscovery(NodeLock objectLockToken, String 
serverURL, String contextPath) {
  -
  +        
           XMLValue xmlValue = new XMLValue();
           Element activelock = createActiveLockElement(objectLockToken,serverURL, 
contextPath);
  -
  +        
           if (activelock != null) {
               xmlValue.add(activelock);
           }
           return xmlValue;
       }
  -
  +    
       /**
        * Returns the <code>&lt;activelock&gt;</code> element to be used as child
        * the <code>&lt;lockdiscovery&gt;</code> property.
  @@ -1214,12 +1345,12 @@
        *
        */
       private Element createActiveLockElement(NodeLock objectLockToken, String 
serverURL, String contextPath) {
  -
  +        
           Element activelock = null;
           Security security = nsaToken.getSecurityHelper();
  -
  +        
           if (objectLockToken != null) {
  -
  +            
               activelock = new Element(E_ACTIVELOCK, 
NamespaceCache.DEFAULT_NAMESPACE);
               Element locktype = new Element(E_LOCKTYPE, 
NamespaceCache.DEFAULT_NAMESPACE);
               activelock.addContent(locktype);
  @@ -1250,7 +1381,7 @@
                */
               if( objectLockToken.getOwnerInfo() != null &&
                  
!objectLockToken.getOwnerInfo().equals(LockMethod.DEFAULT_LOCK_OWNER) ) {
  -
  +                
                   // try to parse
                   try {
                       Document d =
  @@ -1261,7 +1392,7 @@
                       owner.addContent(new CDATA(objectLockToken.getOwnerInfo()));
                   }
               }
  -
  +            
               Element timeout = new Element(E_TIMEOUT, 
NamespaceCache.DEFAULT_NAMESPACE);
               activelock.addContent(timeout);
               timeout.setText("Second-"
  @@ -1272,8 +1403,8 @@
               activelock.addContent(locktoken);
               Element href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
               locktoken.addContent(href);
  -                href.setText("opaquelocktoken:" + objectLockToken.getLockId());
  -
  +            href.setText(S_LOCK_TOKEN+objectLockToken.getLockId());
  +            
               // As proposed on February 08, 2003 by Lisa Dusseault in [EMAIL 
PROTECTED]
               // >>>>>>>>>> start principal-URL >>>>>>>>>>>>
               if( lockdiscoveryIncludesPrincipalURL ) {
  @@ -1287,7 +1418,7 @@
           }
           return activelock;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the value of the 
<code>&lt;supportedlock&gt;</code>
        * property.
  @@ -1311,9 +1442,9 @@
        * @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, 
NamespaceCache.DEFAULT_NAMESPACE);
           Element lockscope = new Element(E_LOCKSCOPE, 
NamespaceCache.DEFAULT_NAMESPACE);
           lockentry.addContent(lockscope);
  @@ -1324,7 +1455,7 @@
           Element write = new Element(E_WRITE, NamespaceCache.DEFAULT_NAMESPACE);
           locktype.addContent(write);
           xmlValue.add(lockentry);
  -
  +        
           lockentry = new Element(E_LOCKENTRY, NamespaceCache.DEFAULT_NAMESPACE);
           lockscope = new Element(E_LOCKSCOPE, NamespaceCache.DEFAULT_NAMESPACE);
           lockentry.addContent(lockscope);
  @@ -1335,11 +1466,11 @@
           write = new Element(E_WRITE, NamespaceCache.DEFAULT_NAMESPACE);
           locktype.addContent(write);
           xmlValue.add(lockentry);
  -
  +        
           return xmlValue;
       }
  -
  -
  +    
  +    
       /**
        * Returns an XMLValue containing the value of the 
<code>&lt;supported-privilege-set&gt;</code>
        * property.
  @@ -1363,33 +1494,33 @@
        * @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, 
NamespaceCache.DEFAULT_NAMESPACE);
           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, 
NamespaceCache.DEFAULT_NAMESPACE);
           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, 
NamespaceCache.DEFAULT_NAMESPACE);
           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>.
  @@ -1401,7 +1532,7 @@
       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>.
  @@ -1423,7 +1554,7 @@
           privilege.addContent(privilegeNameElement);
           return privilege;
       }
  -
  +    
       /**
        * Creates a <code>&lt;description&gt;</code> element with the given
        * <code>text</code>.
  @@ -1437,7 +1568,7 @@
           description.setText(text);
           return description;
       }
  -
  +    
       /**
        * Returns an XMLValue containing the value of the
        * <code>&lt;current-user-privilege-set&gt;</code> property.
  @@ -1461,15 +1592,15 @@
        * @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) {
  @@ -1477,9 +1608,9 @@
           } catch (ClassCastException e) {
               return xmlValue;
           }
  -
  +        
           try {
  -
  +            
               boolean readObject =
                   security.hasPermission(object, principalNode,
                                          config.getReadObjectAction());
  @@ -1531,7 +1662,7 @@
               boolean removeRevisionContent = security.hasPermission
                   (object, principalNode,
                    config.getRemoveRevisionContentAction());
  -
  +            
               boolean canRead = readObject && readRevisionMetadata
                   && readRevisionContent;
               boolean canWrite = createObject && removeObject && lockObject
  @@ -1543,7 +1674,7 @@
               boolean canWriteAcl = grantPermission && revokePermission;
               boolean canAll = canRead && canWrite && canReadAcl && canWriteAcl
                   && killLock;
  -
  +            
               if (canRead) {
                   xmlValue.add(createPrivilege(E_READ));
               }
  @@ -1559,14 +1690,14 @@
               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.
  @@ -1590,28 +1721,28 @@
        * @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, NamespaceCache.DEFAULT_NAMESPACE);
  -//        xmlValue.add(acl);
  -
  +        
  +        //        Element acl = new Element(E_ACL, 
NamespaceCache.DEFAULT_NAMESPACE);
  +        //        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();
  @@ -1629,29 +1760,29 @@
               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()) {
  @@ -1660,24 +1791,24 @@
                       }
                       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);
  @@ -1688,32 +1819,30 @@
                       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++)
  -                    {
  +                    for (int i=0; i<permissions.size() ; i++) {
                           NodePermission otherPermission = (NodePermission) 
permissions.get(i);
  -                        if (principal.equals(otherPermission.getSubjectUri()) && 
(negative==otherPermission.isNegative()))
  -                        {
  +                        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);
  @@ -1724,40 +1853,40 @@
                               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;
  -
  +                    
                       boolean isUnknown = !(isRead || isWrite || isReadAcl || 
isWriteAcl);
  -
  +                    
                       // start generating XML
                       Element ace = new Element(E_ACE, 
NamespaceCache.DEFAULT_NAMESPACE);
                       xmlValue.add(ace);
  -
  +                    
                       ace.addContent(createPrincipal(principal, contextPath));
  -
  +                    
                       Element permissionElement = null;
                       if (permission.isNegative()) {
                           permissionElement = new Element(E_DENY, 
NamespaceCache.DEFAULT_NAMESPACE);
  @@ -1765,7 +1894,7 @@
                           permissionElement = new Element(E_GRANT, 
NamespaceCache.DEFAULT_NAMESPACE);
                       }
                       ace.addContent(permissionElement);
  -
  +                    
                       if (isAll) {
                           permissionElement.addContent(createPrivilege(E_ALL, true));
                       } else {
  @@ -1820,8 +1949,8 @@
                               
permissionElement.addContent(createPrivilege(unkonwnPrivilege, true));
                           }
                       }
  -
  -
  +                    
  +                    
                       if (inheritedPermissions) {
                           ace.addContent(new Element(E_PROTECTED, 
NamespaceCache.DEFAULT_NAMESPACE));
                           Element inherited = new Element(E_INHERITED, 
NamespaceCache.DEFAULT_NAMESPACE);
  @@ -1830,25 +1959,25 @@
                           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
  @@ -1860,9 +1989,9 @@
        * @return     the <code>&lt;principal&gt;</code> element.
        */
       private Element createPrincipal(String principalName, String contextPath) {
  -
  +        
           Element principal = new Element(E_PRINCIPAL, 
NamespaceCache.DEFAULT_NAMESPACE);
  -
  +        
           // FIXME: Apparently, there are or will be some other cases, but it
           // isn't very clear in the spec
           if (principalName.equals("~")) {
  @@ -1874,10 +2003,10 @@
               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.
  @@ -1901,23 +2030,23 @@
        * @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, 
NamespaceCache.DEFAULT_NAMESPACE);
           xmlValue.add(aceCombination);
           Element allGrantBeforeDeny = new Element(E_ALL_GRANT_BEFORE_DENY, 
NamespaceCache.DEFAULT_NAMESPACE);
           aceCombination.addContent(allGrantBeforeDeny);
  -
  +        
           Element requiredPrincipal = new Element(E_REQUIRED_PRINCIPAL, 
NamespaceCache.DEFAULT_NAMESPACE);
           xmlValue.add(requiredPrincipal);
           Element all = new Element(E_ALL, NamespaceCache.DEFAULT_NAMESPACE);
           requiredPrincipal.addContent(all);
  -
  +        
           return xmlValue;
       }
  -
  -
  +    
  +    
       /**
        * Returns an XMLValue containing the value of the
        * <code>&lt;principal-collection-set&gt;</code> property.
  @@ -1941,18 +2070,18 @@
        * @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, NamespaceCache.DEFAULT_NAMESPACE);
           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.
  @@ -1978,7 +2107,7 @@
        * @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,
  @@ -1990,14 +2119,14 @@
                   (!"".equals(ownerProperty.getValue().toString()))) {
               
               if (userCollection == null){
  -            ownerHref = contextPath + config.getUsersPath() + "/" + 
ownerProperty.getValue().toString();
  +                ownerHref = contextPath + config.getUsersPath() + "/" + 
ownerProperty.getValue().toString();
               } else {
                   ownerHref = contextPath + config.getUsersPath() + "/" + 
userCollection + "/" + ownerProperty.getValue().toString();
  -        }
  +            }
           } else {
               ownerHref =  contextPath + config.getUsersPath();
  -                     if ( config.getGuestPath() != null && 
!config.getGuestPath().equals("") )
  -                             ownerHref = ownerHref + "/" + config.getGuestPath();
  +            if ( config.getGuestPath() != null && !config.getGuestPath().equals("") 
)
  +                ownerHref = ownerHref + "/" + config.getGuestPath();
           }
           Element href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
           href.setText(ownerHref);
  @@ -2005,8 +2134,8 @@
           
           return xmlValue;
       }
  -
  -
  +    
  +    
       /**
        * Returns the concatenation of <code>serverURL</code>, <code>contextPath</code>
        * and <code>uri</code> and inserts all needed slashes.
  @@ -2023,13 +2152,13 @@
        * @return     the concatenated URL.
        */
       public static String getAbsoluteURL(String serverURL, String contextPath, 
String uri) {
  -
  +        
           StringBuffer buffer = new StringBuffer();
           String lastAppended = null;
  -//        if (serverURL != null) {
  -//            buffer.append(serverURL);
  +        //        if (serverURL != null) {
  +        //            buffer.append(serverURL);
           //            lastAppended = buffer.toString();
  -//        }
  +        //        }
           if (contextPath != null) {
               if ( (lastAppended != null) && !lastAppended.endsWith("/") && 
!contextPath.startsWith("/") ) {
                   buffer.append("/");
  @@ -2043,10 +2172,10 @@
               }
               buffer.append(uri);
           }
  -
  +        
           return buffer.toString();
       }
  -
  +    
       /**
        * Returns <code>true</code> if the given <code>uri</code> is an absolute URL.
        *
  @@ -2057,12 +2186,18 @@
        * @return     <code>true</code> if the given <code>uri</code> is an absolute 
URL.
        */
       public static boolean isAbsoluteURL(String serverURL, String contextPath, 
String uri) {
  +        if (uri.startsWith(S_RESOURCE_ID)) {
  +            return true;
  +        }
  +        if (uri.startsWith(S_LOCK_TOKEN)) {
  +            return true;
  +        }
           if (!uri.startsWith("/")) {
               uri = "/" + uri;
           }
           return uri.startsWith(contextPath);
       }
  -
  +    
       /**
        * Adds the given <code>uri</code> as a <code>&lt;href&gt;</code> element
        * to the value of the property (specified by the <code>propertyName</code>)
  @@ -2078,7 +2213,7 @@
       public static void addHrefToProperty(NodeRevisionDescriptor revisionDescriptor, 
String propertyName, String uri) throws JDOMException {
           addElementToProperty(revisionDescriptor, propertyName, E_HREF, uri);
       }
  -
  +    
       /**
        * Adds the given <code>elementValue</code> as a 
<code>&lt;elementName&gt;</code> element
        * to the value of the property (specified by the <code>propertyName</code>)
  @@ -2093,7 +2228,7 @@
        * @throws     JDOMException if parsing the property failed.
        */
       public static void addElementToProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String elementName, String elementValue) 
throws JDOMException {
  -
  +        
           NodeProperty property = revisionDescriptor.getProperty(propertyName);
           if (property == null) {
               property = new NodeProperty(propertyName, null);
  @@ -2115,7 +2250,7 @@
           }
           revisionDescriptor.setProperty(propertyName, xmlValue.toString());
       }
  -
  +    
       /**
        * Removes the <code>&lt;href&gt;</code> element with the given <code>uri</code>
        * from the value of the property (specified by the <code>propertyName</code>)
  @@ -2132,7 +2267,7 @@
       public static void removeHrefFromProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String uri) throws JDOMException {
           removeElementFromProperty(revisionDescriptor, propertyName, E_HREF, uri);
       }
  -
  +    
       /**
        * Removes the <code>&lt;elementName&gt;</code> element with the given 
<code>elementValue</code>
        * from the value of the property (specified by the <code>propertyName</code>)
  @@ -2147,10 +2282,10 @@
        * @throws     JDOMException if parsing the property failed.
        */
       public static void removeElementFromProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String elementName, String elementValue) 
throws JDOMException {
  -
  +        
           NodeProperty property = revisionDescriptor.getProperty(propertyName);
           if (property != null) {
  -
  +            
               XMLValue xmlValue = new XMLValue((String)property.getValue());
               Iterator iterator = xmlValue.iterator();
               boolean found = false;
  @@ -2167,7 +2302,7 @@
               }
           }
       }
  -
  +    
       /**
        * Any leading <code>/</code> in the given <code>uri</code> will be removed.
        *
  @@ -2176,33 +2311,33 @@
        * @return     the Uri without leading slashes.
        */
       public static String truncateLeadingSlash(String uri) {
  -
  +        
           if (uri == null) {
               return uri;
           }
  -
  +        
           while (uri.startsWith("/")) {
               uri = uri.substring(1);
           }
           return uri;
       }
  -
  -
  -
  -
  +    
  +    
  +    
  +    
       /**
        * MD5 message digest provider.
        */
       protected static MessageDigest md5Helper;
  -
  -
  +    
  +    
       /**
        * The MD5 helper object for this class.
        */
       protected static final MD5Encoder md5Encoder = new MD5Encoder();
  -
  +    
       static {
  -
  +        
           // Load the MD5 helper used to calculate signatures.
           try {
               md5Helper = MessageDigest.getInstance("MD5");
  @@ -2210,11 +2345,11 @@
               e.printStackTrace();
               throw new IllegalStateException();
           }
  -
  +        
       }
  -
  -
  -
  +    
  +    
  +    
       /**
        * Any leading <code>/</code> in the given <code>uri</code> will be removed.
        *
  @@ -2224,13 +2359,13 @@
        */
       public static String computeEtag(String uri, NodeRevisionDescriptor nrd) {
           String result = System.currentTimeMillis() + "_"
  -                        + uri.hashCode() + "_"
  -                        + nrd.getLastModified() + "_"
  -                        + nrd.getContentLength();
  +            + uri.hashCode() + "_"
  +            + nrd.getLastModified() + "_"
  +            + nrd.getContentLength();
           result = md5Encoder.encode(md5Helper.digest(result.getBytes()));
           return result;
       }
  -
  +    
   }
   
   
  
  
  

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

Reply via email to