pnever      2003/09/01 09:51:35

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        VersioningHelper.java PropertyHelper.java
  Log:
  TEMPORARY:
  Binding and DeltaV: on CHECKIN / UNCHECKOUT the same path as
  used for CHECKOUT must be used
  
  Revision  Changes    Path
  1.89      +30 -5     
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.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- VersioningHelper.java     18 Aug 2003 07:03:41 -0000      1.88
  +++ VersioningHelper.java     1 Sep 2003 16:51:35 -0000       1.89
  @@ -90,6 +90,7 @@
   import org.apache.slide.lock.LockTokenNotFoundException;
   import org.apache.slide.lock.NodeLock;
   import org.apache.slide.lock.ObjectLockedException;
  +import org.apache.slide.macro.ConflictException;
   import org.apache.slide.macro.Macro;
   import org.apache.slide.search.BadQueryException;
   import org.apache.slide.search.Search;
  @@ -1061,7 +1062,19 @@
           NodeRevisionContent coutNrc = content.retrieve( sToken, coutNrds, coutNrd );
   
           // update its DAV:checkout-set property
  -        PropertyHelper.removeHrefFromProperty(coutNrd, P_CHECKOUT_SET, rUri);
  +        if (!PropertyHelper.removeHrefFromProperty(coutNrd, P_CHECKOUT_SET, rUri)) {
  +            StringBuffer b = new StringBuffer("Invalid path");
  +            PropertyHelper propertyHelper = 
PropertyHelper.getPropertyHelper(sToken, nsaToken, sConf);
  +            NodeProperty checkoutSetProp = 
propertyHelper.getProperty(P_CHECKOUT_SET, coutNrds, coutNrd, req.getContextPath(), 
null);
  +            if( checkoutSetProp != null && checkoutSetProp.getValue() != null ) {
  +                XMLValue checkoutSetValue = new XMLValue( 
checkoutSetProp.getValue().toString() );
  +                if (checkoutSetValue.iterator().hasNext()) {
  +                    b.append(" - please use "+checkoutSetValue.getTextValue()+" 
instead");
  +                }
  +            }
  +            throw new ConflictException(
  +                rUri, new SlideException(b.toString()));
  +        }
           content.store(sToken, coutNrds.getUri(), coutNrd, null);
   
           // update VCR to previous VR
  @@ -1161,7 +1174,19 @@
                   content.retrieve( sToken, vhrNrds, vrNrnOld ); // vrUriOld
   
               // update the old VR's DAV:checkout-set property
  -            PropertyHelper.removeHrefFromProperty(vrNrdOld, P_CHECKOUT_SET, rUri);
  +            if (!PropertyHelper.removeHrefFromProperty(vrNrdOld, P_CHECKOUT_SET, 
rUri)) {
  +                StringBuffer b = new StringBuffer("Invalid path");
  +                PropertyHelper propertyHelper = 
PropertyHelper.getPropertyHelper(sToken, nsaToken, sConf);
  +                NodeProperty checkoutSetProp = 
propertyHelper.getProperty(P_CHECKOUT_SET, vhrNrds, vrNrdOld, req.getContextPath(), 
null);
  +                if( checkoutSetProp != null && checkoutSetProp.getValue() != null ) 
{
  +                    XMLValue checkoutSetValue = new XMLValue( 
checkoutSetProp.getValue().toString() );
  +                    if (checkoutSetValue.iterator().hasNext()) {
  +                        b.append(" - please use "+checkoutSetValue.getTextValue()+" 
instead");
  +                    }
  +                }
  +                throw new ConflictException(
  +                    rUri, new SlideException(b.toString()));
  +            }
               content.store(sToken, vhrNrds.getUri(), vrNrdOld, null);
   
               ViolatedPrecondition violatedPrecondition =
  
  
  
  1.50      +21 -14    
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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- PropertyHelper.java       18 Aug 2003 07:01:27 -0000      1.49
  +++ PropertyHelper.java       1 Sep 2003 16:51:35 -0000       1.50
  @@ -2207,11 +2207,12 @@
        *                                 update the property.
        * @param      propertyName        the name of the property to add the uri to.
        * @param      uri                 the uri to add as a 
<code>&lt;href&gt;</code> element.
  +     * @return     true, if href was added; false, if already contained
  +     * @throws   JDOMException
        *
  -     * @throws     JDOMException if parsing the property failed.
        */
  -    public static void addHrefToProperty(NodeRevisionDescriptor revisionDescriptor, 
String propertyName, String uri) throws JDOMException {
  -        addElementToProperty(revisionDescriptor, propertyName, E_HREF, uri);
  +    public static boolean addHrefToProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String uri) throws JDOMException {
  +        return addElementToProperty(revisionDescriptor, propertyName, E_HREF, uri);
       }
       
       /**
  @@ -2224,10 +2225,11 @@
        * @param      propertyName        the name of the property to add the element 
to.
        * @param      elementName         the name of the element to add.
        * @param      elementValue        the value to add as a 
<code>&lt;elementName&gt;</code> element.
  +     * @return     true, if element was added; false, if already contained
  +     * @throws   JDOMException
        *
  -     * @throws     JDOMException if parsing the property failed.
        */
  -    public static void addElementToProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String elementName, String elementValue) 
throws JDOMException {
  +    public static boolean addElementToProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String elementName, String elementValue) 
throws JDOMException {
           
           NodeProperty property = revisionDescriptor.getProperty(propertyName);
           if (property == null) {
  @@ -2249,6 +2251,7 @@
               xmlValue.add(element);
           }
           revisionDescriptor.setProperty(propertyName, xmlValue.toString());
  +        return !alreadyContained;
       }
       
       /**
  @@ -2261,11 +2264,12 @@
        * @param      propertyName        the name of the property to remove the uri 
from.
        * @param      uri                 the uri of the <code>&lt;href&gt;</code> 
element
        *                                 to remove.
  +     * @return     true, if href was removed; false, if not found
  +     * @throws   JDOMException
        *
  -     * @throws     JDOMException if parsing the property failed.
        */
  -    public static void removeHrefFromProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String uri) throws JDOMException {
  -        removeElementFromProperty(revisionDescriptor, propertyName, E_HREF, uri);
  +    public static boolean removeHrefFromProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String uri) throws JDOMException {
  +        return removeElementFromProperty(revisionDescriptor, propertyName, E_HREF, 
uri);
       }
       
       /**
  @@ -2278,17 +2282,19 @@
        * @param      propertyName        the name of the property to add the element 
to.
        * @param      elementName         the name of the element to add.
        * @param      elementValue        the value to add as a 
<code>&lt;elementName&gt;</code> element.
  +     * @return     true, if element was removed; false, if not found
  +     *
  +     * @throws   JDOMException
        *
  -     * @throws     JDOMException if parsing the property failed.
        */
  -    public static void removeElementFromProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String elementName, String elementValue) 
throws JDOMException {
  +    public static boolean removeElementFromProperty(NodeRevisionDescriptor 
revisionDescriptor, String propertyName, String elementName, String elementValue) 
throws JDOMException {
           
           NodeProperty property = revisionDescriptor.getProperty(propertyName);
  +        boolean found = false;
           if (property != null) {
               
               XMLValue xmlValue = new XMLValue((String)property.getValue());
               Iterator iterator = xmlValue.iterator();
  -            boolean found = false;
               Element element = null;
               while (iterator.hasNext() && !found) {
                   element = (Element)iterator.next();
  @@ -2301,6 +2307,7 @@
                   revisionDescriptor.setProperty(propertyName, xmlValue.toString());
               }
           }
  +        return found;
       }
       
       /**
  
  
  

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

Reply via email to