juergen     02/04/25 05:30:59

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        VersioningHelper.java
  Log:
  Added method retrieveLabeledRevision().
  Added another signature of the retrieveLatestRevisionDescriptor() method which takes 
a label as an additional parameter.
  (ralf)
  
  Revision  Changes    Path
  1.33      +137 -3    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
  
  Index: VersioningHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- VersioningHelper.java     23 Apr 2002 08:16:39 -0000      1.32
  +++ VersioningHelper.java     25 Apr 2002 12:30:59 -0000      1.33
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
 1.32 2002/04/23 08:16:39 pnever Exp $
  - * $Revision: 1.32 $
  - * $Date: 2002/04/23 08:16:39 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
 1.33 2002/04/25 12:30:59 juergen Exp $
  + * $Revision: 1.33 $
  + * $Date: 2002/04/25 12:30:59 $
    *
    * ====================================================================
    *
  @@ -215,6 +215,13 @@
       /**
        * Retrieve the latest DeltaV-compliant NRD instance for the specified
        * resource path and associated to the specified NRDS instance.
  +     *
  +     * @param      resourcePath  the path of the resource for which to retrieve
  +     *                           the NRD.
  +     * @param      rNrds         the NodeRevisionDescriptors of the resource.
  +     *
  +     * @return     the latest DeltaV-compliant NRD instance for the specified
  +     *             resource path and associated to the specified NRDS instance.
        */
       public NodeRevisionDescriptor
       retrieveLatestRevisionDescriptor( String resourcePath, NodeRevisionDescriptors 
rNrds ) throws SlideException {
  @@ -223,6 +230,42 @@
       }
       
       /**
  +     * Retrieve the latest DeltaV-compliant NRD instance for the specified
  +     * resource path and associated to the specified NRDS instance.
  +     *
  +     * @param      resourcePath  the path of the resource for which to retrieve
  +     *                           the NRD.
  +     * @param      rNrds         the NodeRevisionDescriptors of the resource.
  +     * @param      label         if the <code>label</code> is not null and the
  +     *                           <code>resourcePath</code> identifies a VCR,
  +     *                           the associated revision with that label is 
returned.
  +     *
  +     * @return     the latest DeltaV-compliant NRD instance for the specified
  +     *             resource path and associated to the specified NRDS instance.
  +     */
  +    public NodeRevisionDescriptor
  +        retrieveLatestRevisionDescriptor( String resourcePath, 
NodeRevisionDescriptors rNrds, String label) throws SlideException {
  +        
  +        return retrieveLatestRevisionDescriptor(nsaToken, sToken, content, 
resourcePath, rNrds, label);
  +    }
  +    
  +    /**
  +     * If the <code>resourcePath</code> identifies a VCR, the associated revision
  +     * with the given <code>label</code> is returned. If the 
<code>resourcePath</code>
  +     * does not identify a VCR or if no revision with the given <code>label</code>
  +     * is found, <code>null</code> is returned.
  +     *
  +     * @param      resourcePath  the path of the resource for which to retrieve
  +     *                           the NRD.
  +     * @param      label         the label of the revision to return.
  +     *
  +     * @return     the associated revision with the given <code>label</code>.
  +     */
  +    public NodeRevisionDescriptor retrieveLabeledRevision(String resourcePath, 
String label) throws SlideException {
  +        return retrieveLabeledRevision(nsaToken, sToken, content, resourcePath, 
label);
  +    }
  +        
  +    /**
        * Set the specified resource under version control
        *
        * @param resourcePath the URI of the resource to version-control
  @@ -1447,6 +1490,32 @@
                                                                             Content 
content,
                                                                             String 
resourcePath,
                                                                             
NodeRevisionDescriptors rNrds) throws SlideException {
  +        return retrieveLatestRevisionDescriptor(nsaToken, sToken, content, 
resourcePath, rNrds, null);
  +    }
  +    
  +    /**
  +     * Retrieve the latest DeltaV-compliant NRD instance for the specified
  +     * resource path and associated to the specified NRDS instance.
  +     *
  +     * @param      nsaToken      the NamespaceAccessToken to use.
  +     * @param      sToken        the SlideToken to use.
  +     * @param      content       the Content helper to use.
  +     * @param      resourcePath  the path of the resource for which to retrieve
  +     *                           the NRD.
  +     * @param      rNrds         the NodeRevisionDescriptors of the resource.
  +     * @param      label         if the <code>label</code> is not null and the
  +     *                           <code>resourcePath</code> identifies a VCR,
  +     *                           the associated revision with that label is 
returned.
  +     *
  +     * @return     the latest DeltaV-compliant NRD instance for the specified
  +     *             resource path and associated to the specified NRDS instance.
  +     */
  +    public static NodeRevisionDescriptor 
retrieveLatestRevisionDescriptor(NamespaceAccessToken nsaToken,
  +                                                                          
SlideToken sToken,
  +                                                                          Content 
content,
  +                                                                          String 
resourcePath,
  +                                                                          
NodeRevisionDescriptors rNrds,
  +                                                                          String 
label) throws SlideException {
           
           NodeRevisionDescriptor rNrd = null;
           UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
  @@ -1461,9 +1530,74 @@
           }
           else {
               rNrd = content.retrieve( sToken, rNrds );
  +            if (label != null) {
  +                rNrd = retrieveLabeledRevision(nsaToken, sToken, content, 
resourcePath, label);
  +            }
           }
           
           return rNrd;
  +    }
  +    
  +    /**
  +     * If the <code>resourcePath</code> identifies a VCR, the associated revision
  +     * with the given <code>label</code> is returned. If the 
<code>resourcePath</code>
  +     * does not identify a VCR or if no revision with the given <code>label</code>
  +     * is found, <code>null</code> is returned.
  +     *
  +     * @param      nsaToken      the NamespaceAccessToken to use.
  +     * @param      sToken        the SlideToken to use.
  +     * @param      content       the Content helper to use.
  +     * @param      resourcePath  the path of the resource for which to retrieve
  +     *                           the NRD.
  +     * @param      label         the label of the revision to return.
  +     *
  +     * @return     the associated revision with the given <code>label</code>.
  +     */
  +    public static NodeRevisionDescriptor 
retrieveLabeledRevision(NamespaceAccessToken nsaToken, SlideToken sToken, Content 
content, String resourcePath, String label) throws SlideException {
  +        
  +        NodeRevisionDescriptor labeledRevision = null;
  +        
  +        String vrUri = getUriOfAssociatedVR(nsaToken, sToken, content, 
resourcePath);
  +        if (vrUri != null) {
  +            
  +            UriHandler vrUriHandler = UriHandler.getUriHandler(nsaToken, vrUri);
  +            String historyUri = vrUriHandler.getAssociatedHistoryUri();
  +            NodeRevisionDescriptors historyNrds = 
retrieveRevisionDescriptors(nsaToken, sToken, content, historyUri);
  +            NodeRevisionDescriptor historyNrd = content.retrieve(sToken, 
historyNrds, new NodeRevisionNumber(0, 0));
  +            NodeProperty versionSet = historyNrd.getProperty(P_VERSION_SET);
  +            try {
  +                XMLValue versionSetValue = new 
XMLValue(versionSet.getValue().toString());
  +                NodeRevisionDescriptor vrNrd = null;
  +                NodeProperty labelNameSetProperty = null;
  +                String labelNameSetString = null;
  +                Iterator versionSetIterator = versionSetValue.iterator();
  +                boolean found = false;
  +                while ( !found && versionSetIterator.hasNext() ) {
  +                    vrUri = ((Element)versionSetIterator.next()).getText();
  +                    vrUriHandler = UriHandler.getUriHandler(nsaToken, vrUri);
  +                    NodeRevisionNumber vrRevisionNumber = new 
NodeRevisionNumber(vrUriHandler.getVersionName());
  +                    vrNrd = content.retrieve(sToken, historyNrds, vrRevisionNumber);
  +                    labelNameSetProperty = vrNrd.getProperty(P_LABEL_NAME_SET);
  +                    if ( (labelNameSetProperty != null) && 
(labelNameSetProperty.getValue() != null) ) {
  +                        labelNameSetString = 
labelNameSetProperty.getValue().toString();
  +                        if (labelNameSetString != null) {
  +                            XMLValue labelNameSet = new 
XMLValue(labelNameSetString);
  +                            Iterator labelNameSetIterator = labelNameSet.iterator();
  +                            while ( !found && labelNameSetIterator.hasNext() ) {
  +                                found = 
label.equals(((Element)labelNameSetIterator.next()).getText());
  +                            }
  +                        }
  +                    }
  +                }
  +                if (found) {
  +                    labeledRevision = vrNrd;
  +                }
  +                
  +            }
  +            catch (JDOMException e) {}
  +            catch (IllegalArgumentException e) {}
  +        }
  +        return labeledRevision;
       }
       
       
  
  
  

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

Reply via email to