juergen     02/04/26 04:56:39

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        PropertyHelper.java
  Log:
  Replaced set of specific Exceptions by one SlideException.
  Added methods computeCheckoutSet() and computeWorkspaceCheckoutSet().
  (ralf)
  
  Revision  Changes    Path
  1.14      +191 -38   
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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- PropertyHelper.java       25 Apr 2002 21:27:31 -0000      1.13
  +++ PropertyHelper.java       26 Apr 2002 11:56:39 -0000      1.14
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
 1.13 2002/04/25 21:27:31 jericho Exp $
  - * $Revision: 1.13 $
  - * $Date: 2002/04/25 21:27:31 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
 1.14 2002/04/26 11:56:39 juergen Exp $
  + * $Revision: 1.14 $
  + * $Date: 2002/04/26 11:56:39 $
    *
    * ====================================================================
    *
  @@ -72,10 +72,13 @@
   import org.jdom.JDOMException;
   import org.jdom.Namespace;
   
  +import org.jdom.output.DOMOutputter;
  +
   import org.apache.slide.common.Domain;
   import org.apache.slide.common.SlideToken;
   import org.apache.slide.common.NamespaceAccessToken;
   import org.apache.slide.common.ServiceAccessException;
  +import org.apache.slide.common.SlideException;
   
   import org.apache.slide.content.NodeProperty;
   import org.apache.slide.content.NodeRevisionDescriptor;
  @@ -93,6 +96,11 @@
   
   import org.apache.slide.webdav.util.resourcekind.*;
   
  +import org.apache.slide.search.SearchQuery;
  +import org.apache.slide.search.SearchQueryResult;
  +import org.apache.slide.search.Search;
  +import org.apache.slide.search.RequestedResource;
  +import org.apache.slide.search.BadQueryException;
   
   /**
    * Helper class for handling WebDAV resources.
  @@ -388,15 +396,10 @@
        *
        * @return   the property.
        *
  -     * @throws   ObjectLockedException
  -     * @throws   RevisionDescriptorNotFoundException
  -     * @throws   ServiceAccessException
  -     * @throws   LinkedObjectNotFoundException
  -     * @throws   AccessDeniedException
  -     * @throws   ObjectNotFoundException
  +     * @throws   SlideException
        * @throws   JDOMException
        */
  -    public NodeProperty getProperty(String propertyName, String resourcePath) 
throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, JDOMException {
  +    public NodeProperty getProperty(String propertyName, String resourcePath) 
throws SlideException, JDOMException {
           return getProperty(propertyName, resourcePath, null, null);
       }
       
  @@ -413,15 +416,10 @@
        *
        * @return   the property.
        *
  -     * @throws   ObjectLockedException
  -     * @throws   RevisionDescriptorNotFoundException
  -     * @throws   ServiceAccessException
  -     * @throws   LinkedObjectNotFoundException
  -     * @throws   AccessDeniedException
  -     * @throws   ObjectNotFoundException
  +     * @throws   SlideException
        * @throws   JDOMException
        */
  -    public NodeProperty getProperty(String propertyName, String resourcePath, 
String contextPath, String serverURL) throws ObjectLockedException, 
RevisionDescriptorNotFoundException, ServiceAccessException, 
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, 
JDOMException {
  +    public NodeProperty getProperty(String propertyName, String resourcePath, 
String contextPath, String serverURL) throws SlideException, JDOMException {
           
           UriHandler uriHandler = UriHandler.getUriHandler(nsaToken, resourcePath);
           String uri = null;
  @@ -459,15 +457,10 @@
        *
        * @return   the property.
        *
  -     * @throws   ObjectLockedException
  -     * @throws   RevisionDescriptorNotFoundException
  -     * @throws   ServiceAccessException
  -     * @throws   LinkedObjectNotFoundException
  -     * @throws   AccessDeniedException
  -     * @throws   ObjectNotFoundException
  +     * @throws   SlideException
        * @throws   JDOMException
        */
  -    public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws 
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException, 
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, 
JDOMException {
  +    public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws SlideException, 
JDOMException {
           return getProperty(propertyName, revisionDescriptors, revisionDescriptor, 
null, null);
       }
       
  @@ -486,15 +479,10 @@
        *
        * @return   the property.
        *
  -     * @throws   ObjectLockedException
  -     * @throws   RevisionDescriptorNotFoundException
  -     * @throws   ServiceAccessException
  -     * @throws   LinkedObjectNotFoundException
  -     * @throws   AccessDeniedException
  -     * @throws   ObjectNotFoundException
  +     * @throws   SlideException
        * @throws   JDOMException
        */
  -    public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, JDOMException {
  +    public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws SlideException, JDOMException {
           
           NodeProperty property = null;
           ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(revisionDescriptor);
  @@ -521,15 +509,10 @@
        *
        * @return   the property.
        *
  -     * @throws   ObjectLockedException
  -     * @throws   RevisionDescriptorNotFoundException
  -     * @throws   ServiceAccessException
  -     * @throws   LinkedObjectNotFoundException
  -     * @throws   AccessDeniedException
  -     * @throws   ObjectNotFoundException
  +     * @throws   SlideException
        * @throws   JDOMException
        */
  -    public NodeProperty computeProperty(String propertyName, 
NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor 
revisionDescriptor, String contextPath, String serverURL) throws 
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException, 
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, 
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)) {
  @@ -550,6 +533,12 @@
           else if (P_SUPPORTED_REPORT_SET.equals(propertyName)) {
               property = new NodeProperty(propertyName, 
computeSupportedReportSet(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
           }
  +        else if (P_CHECKOUT_SET.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeCheckoutSet(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
  +        }
  +        else if (P_WORKSPACE_CHECKOUT_SET.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeWorkspaceCheckoutSet(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
  +        }
           
           return property;
       }
  @@ -836,6 +825,170 @@
               propertyElement = new Element((String)iterator.next());
               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>
  +     * property pointing to this VR.
  +     * If the resource is not a VR, the returned XMLValue is empty.
  +     * The difference to the other
  +     * {@link #computeCheckoutSet(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
computeCheckoutSet()}
  +     * method signature is that the <code>&lt;href&gt;</code> contain only
  +     * the slide URI and not the complete URI that is to be returned by e.g.
  +     * PROPFIND.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the VR.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the VR.
  +     *
  +     * @return   the value of the <code>&lt;checkout-set&gt;</code> property.
  +     *
  +     * @throws   SlideException
  +     * @throws   JDOMException
  +     */
  +    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>
  +     * property pointing to this VR.
  +     * If the resource is not a VR, the returned XMLValue is empty.
  +     *
  +     * @param    revisionDescriptors  the NodeRevisionDescriptors of the VR.
  +     * @param    revisionDescriptor   the NodeRevisionDescriptor of the VR.
  +     * @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;checkout-set&gt;</code> property.
  +     *
  +     * @throws   SlideException
  +     * @throws   JDOMException
  +     */
  +    public XMLValue computeCheckoutSet(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
throws SlideException, JDOMException {
  +        
  +        XMLValue xmlValue = new XMLValue();
  +        
  +        ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(revisionDescriptor);
  +        if (resourceKind instanceof Version) {
  +            
  +            Element basicSearch = new Element(DaslConstants.E_BASICSEARCH, 
davNamespace);
  +            
  +            Element select = new Element(DaslConstants.E_SELECT, davNamespace);
  +            basicSearch.addContent(select);
  +            Element prop = new Element(E_PROP, davNamespace);
  +            select.addContent(prop);
  +            Element checkedOut = new Element(P_CHECKED_OUT, davNamespace);
  +            prop.addContent(checkedOut);
  +            
  +            Element from = new Element(DaslConstants.E_FROM, davNamespace);
  +            basicSearch.addContent(from);
  +            Element scope = new Element(DaslConstants.E_SCOPE, davNamespace);
  +            from.addContent(scope);
  +            Element href = new Element(E_HREF, davNamespace);
  +            scope.addContent(href);
  +            href.setText("/");
  +            
  +            Element where = new Element(DaslConstants.E_WHERE, davNamespace);
  +            basicSearch.addContent(where);
  +            Element propcontains = new Element(DaslConstants.E_PROPCONTAINS, 
slideNamespace);
  +            where.addContent(propcontains);
  +            propcontains.addContent((Element)prop.clone());
  +            Element literal = new Element(DaslConstants.E_LITERAL, davNamespace);
  +            propcontains.addContent(literal);
  +            literal.setText(VersioningHelper.getUri(nsaToken, sToken, 
nsaToken.getContentHelper(), revisionDescriptors, revisionDescriptor));
  +            
  +            String grammarNamespace = basicSearch.getNamespaceURI();
  +            Search searchHelper = nsaToken.getSearchHelper();
  +            SearchQuery searchQuery = 
searchHelper.createSearchQuery(grammarNamespace,
  +                                                                     new 
DOMOutputter().output(basicSearch),
  +                                                                     sToken,
  +                                                                     
Integer.MAX_VALUE);
  +            SearchQueryResult queryResult = searchHelper.search(sToken, 
searchQuery);
  +            Iterator queryResultIterator = queryResult.iterator();
  +            RequestedResource requestedResource = null;
  +            while (queryResultIterator.hasNext()) {
  +                requestedResource = (RequestedResource)queryResultIterator.next();
  +                href = new Element(E_HREF, defNamespace);
  +                href.setText(getAbsoluteURL(serverURL, contextPath, 
requestedResource.getInternalHref()));
  +                xmlValue.add(href);
  +            }
  +        }
  +
  +        return xmlValue;
  +    }
  +    
  +    /**
  +     * 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 computeWorkspaceCheckoutSet(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws SlideException, JDOMException {
  +
  +        XMLValue xmlValue = new XMLValue();
  +        
  +        ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(revisionDescriptor);
  +        if (resourceKind instanceof Workspace) {
  +            
  +            Element basicSearch = new Element(DaslConstants.E_BASICSEARCH, 
davNamespace);
  +            
  +            Element select = new Element(DaslConstants.E_SELECT, davNamespace);
  +            basicSearch.addContent(select);
  +            Element prop = new Element(E_PROP, davNamespace);
  +            select.addContent(prop);
  +            Element checkedOut = new Element(P_CHECKED_OUT, davNamespace);
  +            prop.addContent(checkedOut);
  +            
  +            Element from = new Element(DaslConstants.E_FROM, davNamespace);
  +            basicSearch.addContent(from);
  +            Element scope = new Element(DaslConstants.E_SCOPE, davNamespace);
  +            from.addContent(scope);
  +            Element href = new Element(E_HREF, davNamespace);
  +            scope.addContent(href);
  +            href.setText(revisionDescriptors.getUri());
  +            
  +            Element where = new Element(DaslConstants.E_WHERE, davNamespace);
  +            basicSearch.addContent(where);
  +            Element isdefined = new Element(DaslConstants.E_ISDEFINED, 
davNamespace);
  +            where.addContent(isdefined);
  +            isdefined.addContent((Element)prop.clone());
  +            
  +            String grammarNamespace = basicSearch.getNamespaceURI();
  +            Search searchHelper = nsaToken.getSearchHelper();
  +            SearchQuery searchQuery = 
searchHelper.createSearchQuery(grammarNamespace,
  +                                                                     new 
DOMOutputter().output(basicSearch),
  +                                                                     sToken,
  +                                                                     
Integer.MAX_VALUE);
  +            SearchQueryResult queryResult = searchHelper.search(sToken, 
searchQuery);
  +            Iterator queryResultIterator = queryResult.iterator();
  +            RequestedResource requestedResource = null;
  +            while (queryResultIterator.hasNext()) {
  +                requestedResource = (RequestedResource)queryResultIterator.next();
  +                href = new Element(E_HREF, defNamespace);
  +                href.setText(getAbsoluteURL(serverURL, contextPath, 
requestedResource.getInternalHref()));
  +                xmlValue.add(href);
  +            }
           }
           
           return xmlValue;
  
  
  

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

Reply via email to