pnever      02/02/26 03:52:16

  Added:       src/webdav/server/org/apache/slide/webdav/util
                        VersioningHelper.java ReportHelper.java
                        PropertyHelper.java MethodHelper.java
                        HistoryPathHandler.java DaslConstants.java
                        AclConstants.java AbstractWebdavHelper.java
  Log:
  Initial
  
  Revision  Changes    Path
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
  
  Index: VersioningHelper.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  import java.io.*;
  import java.util.*;
  
  import org.jdom.JDOMException;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.slide.common.SlideToken;
  import org.apache.slide.common.Uri;
  import org.apache.slide.common.Domain;
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.structure.Structure;
  import org.apache.slide.structure.SubjectNode;
  import org.apache.slide.content.Content;
  import org.apache.slide.content.NodeProperty;
  import org.apache.slide.content.NodeRevisionContent;
  import org.apache.slide.content.NodeRevisionDescriptor;
  import org.apache.slide.content.NodeRevisionDescriptors;
  import org.apache.slide.content.NodeRevisionNumber;
  import org.apache.slide.webdav.WebdavServletConfig;
  import org.apache.slide.webdav.WebdavException;
  import org.apache.slide.webdav.util.PropertyHelper;
  import org.apache.slide.webdav.util.MethodHelper;
  import org.apache.slide.webdav.util.UriHandler;
  import org.apache.slide.webdav.util.DeltavConstants;
  import org.apache.util.WebdavStatus;
  
  import org.apache.slide.common.SlideException;
  
  
  /**
   * Helper class for versioning operations. Allows to execute the operation from
   * within multiple methods.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
   */
  
  public class VersioningHelper extends AbstractWebdavHelper {
                          
      /**
       * Factory method.
       */
      public static VersioningHelper
      getVersioningHelper( SlideToken sToken, NamespaceAccessToken nsaToken,
      HttpServletRequest req, HttpServletResponse resp, WebdavServletConfig sConf ) {
                               
          return new VersioningHelper( sToken, nsaToken, req, resp, sConf );
      }
      
      private Content content = null;
      private Structure structure = null;
      private HttpServletRequest req = null;
      private HttpServletResponse resp = null;
      private WebdavServletConfig sConf = null;
      
      /**
       * Protected contructor
       */
      protected VersioningHelper( SlideToken sToken, NamespaceAccessToken nsaToken,
      HttpServletRequest req, HttpServletResponse resp, WebdavServletConfig sConf ) {
          super( sToken, nsaToken );
          this.req = req;
          this.resp = resp;
          this.sConf = sConf;
          this.content = nsaToken.getContentHelper();
          this.structure = nsaToken.getStructureHelper();
      }
      
      /**
       * Set the specified resource under version control
       */
      public void versionControl( String resourcePath ) throws SlideException {
          UriHandler uh = UriHandler.getUriHandler( nsaToken, resourcePath );
          PropertyHelper ph = PropertyHelper.getPropertyHelper( sToken,nsaToken );
          MethodHelper mh = MethodHelper.getMethodHelper( sToken,nsaToken );
          Iterator i;
          
          String realPath = resourcePath;
          if( uh.isVersionUri() )
              realPath = uh.getAssociatedHistoryUri();
          
          NodeRevisionDescriptors vcrNrds = content.retrieve( sToken, realPath );
          NodeRevisionDescriptor vcrNrd = content.retrieve( sToken, vcrNrds );
          NodeRevisionContent vcrNrc = content.retrieve( sToken, vcrNrds, vcrNrd );
          String resourceKind = mh.determineResourceKind( vcrNrd );
          
          if( !mh.isSupportedMethod(req.getMethod(), resourceKind) ) {
              resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
              return;
          }
          
          // Check for resourceKind = K_VERSION_CONTROLLED*
          if( resourceKind == K_VERSION_CONTROLLED ) {
              // nothing to do
              resp.setStatus(WebdavStatus.SC_OK);
              return;
          }
          
          // Set initial VR properties
          NodeRevisionDescriptor vrNrd =
              new NodeRevisionDescriptor(req.getContentLength());
          i = ph.createInitialProperties(K_VERSION).iterator();
          while( i.hasNext() )
              vrNrd.setProperty( (NodeProperty)i.next() );
          
          // Set initial VHR properties
          NodeRevisionNumber vhrNrn = new NodeRevisionNumber( 0, 0 ); //major=0; 
minor=0
          Vector vhrLabels = new Vector();
          Hashtable vhrProps = new Hashtable();
          String vhrBranch = NodeRevisionDescriptors.MAIN_BRANCH;
          NodeRevisionDescriptor vhrNrd =
              new NodeRevisionDescriptor( vhrNrn, vhrBranch, vhrLabels, vhrProps );
          i = ph.createInitialProperties(K_VERSION_HISTORY).iterator();
          while( i.hasNext() )
              vhrNrd.setProperty( (NodeProperty)i.next() );
          
          // Set initial VCR properties (do not overwrite existing!!)
          i = ph.createInitialProperties(K_VERSION_CONTROLLED).iterator();
          while( i.hasNext() ) {
              NodeProperty p = (NodeProperty)i.next();
              if( !vcrNrd.exists(p.getName()) )
                  vcrNrd.setProperty( p );
          }
          
          // Create VHR/VR
          UriHandler vhrUri = UriHandler.createNextHistoryUri( sToken, nsaToken );
          String vhrUriStr = String.valueOf( vhrUri );
          SubjectNode vhrNode = new SubjectNode();
          structure.create( sToken, vhrNode, String.valueOf(vhrUri) );
          content.create( sToken, vhrUriStr, true ); //isVersioned=true
          content.create( sToken, vhrUriStr, vrNrd, vcrNrc );
          NodeRevisionDescriptors vhrNrds =
              content.retrieve( sToken, vhrUriStr );
          content.create(
              sToken, vhrUriStr, null, vhrNrd, null ); //branch=null, 
revisionContent=null
          
          // Create VR node
          NodeRevisionNumber vrVersion = vrNrd.getRevisionNumber();
          SubjectNode vrNode = new SubjectNode();
          UriHandler vrUri =
              UriHandler.createVersionUri( nsaToken, vhrUri, String.valueOf(vrVersion) 
);
          String vrUriStr = String.valueOf( vrUri );
          structure.create( sToken, vrNode, String.valueOf(vrUri) );
          
          // Set specific properties
          // First VCR ...
          vcrNrd.setProperty(
              new NodeProperty(P_VERSION_HISTORY, ph.createHrefValue(vhrUriStr)) );
          vcrNrd.setProperty(
              new NodeProperty(P_CHECKED_IN, ph.createHrefValue(vrUriStr)) );
          // ... then VHR ...
          vhrNrd.setETag( vhrUriStr.hashCode()+"_" ); // P_GETETAG
          vhrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
          vhrNrd.setContentLength( 0 ); // P_GETCONTENTLENGTH
          vhrNrd.setName( vhrUri.getHistoryName() ); // P_DISPLAYNAME
          vhrNrd.setProperty(
              new NodeProperty(P_VERSION_SET, ph.createHrefValue(vrUriStr)) );
          vhrNrd.setProperty(
              new NodeProperty(P_ROOT_VERSION, ph.createHrefValue(vrUriStr)) );
          // ... and finally VR ...
          /* Content Type --start-- */
          String contentType = req.getContentType();
          if (contentType == null) {
              contentType = sConf.getServletContext()
                  .getMimeType(resourcePath);
          }
          if (contentType == null) {
              contentType = sConf.getDefaultMimeType();
          }
          vrNrd.setContentType(contentType); // P_GETCONTENTTYPE
          /* Content Type --end-- */
          vrNrd.setName( vrUri.getVersionName() ); // P_DISPLAYNAME
          vrNrd.setContentLanguage( "en" ); // P_GETCONTENTLANGUAGE
          vrNrd.setETag( vrUriStr.hashCode()+"_"+req.getContentLength() ); // P_GETETAG
          vrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
          vrNrd.setProperty(
              new NodeProperty(P_VERSION_HISTORY, ph.createHrefValue(vhrUriStr)) );
          vrNrd.setProperty(
              new NodeProperty(P_VERSION_NAME, vrUri.getVersionName()) );
          
          // Store changes
          content.store( sToken, resourcePath, vcrNrd, null ); //revisionContent=null
          content.store( sToken, vhrUriStr, vhrNrd, null ); //revisionContent=null
          content.store( sToken, vhrUriStr, vrNrd, null ); //revisionContent=null
      }
      
      /**
       * Checkout the specified resource
       */
      public void checkout( String resourcePath, boolean forkOk, boolean 
applyToVersion )
      throws SlideException, JDOMException {
          
          UriHandler uh = UriHandler.getUriHandler( nsaToken, resourcePath );
          PropertyHelper ph = PropertyHelper.getPropertyHelper( sToken,nsaToken );
          MethodHelper mh = MethodHelper.getMethodHelper( sToken,nsaToken );
          Iterator i;
          
          String realPath = resourcePath;
          if( uh.isVersionUri() )
              realPath = uh.getAssociatedHistoryUri();
          
          NodeRevisionDescriptors vcrNrds = content.retrieve( sToken, realPath );
          NodeRevisionDescriptor vcrNrd = content.retrieve( sToken, vcrNrds );
          String resourceKind = mh.determineResourceKind( vcrNrd );
          
          if( !mh.isSupportedMethod(req.getMethod(), resourceKind) ) {
              // check precondition C_MUST_BE_CHECKED_IN
              if( resourceKind == K_CHECKED_OUT_VERSION_CONTROLLED ||
                 resourceKind == K_CHECKED_OUT )
              {
                  resp.setStatus(WebdavStatus.SC_CONFLICT);
                  // TODO: set response error element
                  return;
              }
              resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
              return;
          }
          
          if( resourceKind == K_CHECKED_IN_VERSION_CONTROLLED ) {
              NodeProperty cinProp = vcrNrd.getProperty( P_CHECKED_IN );
              // TODO: check precondition 
C_CHECKOUT_OF_VERSION_WITH_DESCENDANT_IS_FORBIDDEN
              // TODO: check precondition 
C_CHECKOUT_OF_VERSION_WITH_DESCENDANT_IS_DISCOURAGED
              // TODO: check precondition 
C_CHECKOUT_OF_CHECKED_OUT_VERSION_IS_FORBIDDEN
              // TODO: check precondition 
C_CHECKOUT_OF_CHECKED_OUT_VERSION_IS_DISCOURAGED
              
              // do the checkout
              vcrNrd.removeProperty( cinProp );
              vcrNrd.setProperty(
                  new NodeProperty(P_CHECKED_OUT, cinProp.getValue()) );
              vcrNrd.setProperty(
                  new NodeProperty(P_PREDECESSOR_SET, cinProp.getValue()) );
          }
          else if( resourceKind == K_VERSION ) {
              Domain.info(
                  "Working resource feature NOT YET IMPLEMENTED" );
          }
          else {
              Domain.warn(
                  "Do not know how to checkout a '"+resourceKind+"' resource" );
              resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
              return;
          }
      }
  }
  
  
  
  
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/ReportHelper.java
  
  Index: ReportHelper.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/ReportHelper.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  import java.util.*;
  
  import org.apache.slide.common.SlideToken;
  import org.apache.slide.common.NamespaceAccessToken;
  
  
  /**
   * Helper class for handling report resources.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
   */
  
  public class ReportHelper extends AbstractWebdavHelper {
          
      // supported reports
      protected static Set supportedReports = new HashSet();
                  
      // static initialization
      static {
          if( isSupportedFeature(F_ACCESS_CONTROL) ) {
              supportedReports.add( R_ACL_PRINCIPAL_PROPS );
              supportedReports.add( R_PRINCIPAL_MATCH );
              supportedReports.add( R_PRINCIPAL_PROPERTY_SEARCH );
              supportedReports.add( R_PRINCIPAL_SEARCH_PROPERTY_SET );
          }
          if( isSupportedFeature(F_VERSION_CONTROL) ) {
              supportedReports.add( R_VERSION_TREE );
              supportedReports.add( R_EXPAND_PROPERTY );
          }
          if( isSupportedFeature(F_VERSION_HISTORY) ) {
              supportedReports.add( R_LOCATE_BY_HISTORY );
          }
          if( isSupportedFeature(F_MERGE) ) {
              supportedReports.add( R_MERGE_PREVIEW );
          }
          if( isSupportedFeature(F_BASELINE) ) {
              supportedReports.add( R_COMPARE_BASELINE );
          }
          if( isSupportedFeature(F_ACTIVITY) ) {
              supportedReports.add( R_LATEST_ACTIVITY_VERSION );
          }
      }
          
      /**
       * Factory method.
       */
      public static ReportHelper
      getReportHelper( SlideToken sToken, NamespaceAccessToken nsaToken) {
          
          return new ReportHelper( sToken, nsaToken );
      }
      
      
      /**
       * Protected contructor
       */
      protected ReportHelper( SlideToken sToken, NamespaceAccessToken nsaToken ) {
          super( sToken, nsaToken );
      }
      
      /**
       * Return set of supported reports
       */
      public static Set getSupportedReports() {
          return supportedReports;
      }
      
      /**
       *
       */
      public static void main(String[] args) {
          Iterator i, j;
          
          i = supportedFeatures.iterator();
          System.out.println("\nSupported features");
          System.out.println(  "------------------");
          while( i.hasNext() )
              System.out.println("- "+i.next());
          
          i = supportedReports.iterator();
          System.out.println("\nSupported reports");
          System.out.println(  "-----------------");
          while( i.hasNext() )
              System.out.println("- "+i.next());
      }
  }
  
  
  
  
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java
  
  Index: PropertyHelper.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  import java.io.*;
  import java.util.*;
  
  import org.jdom.Document;
  import org.jdom.Element;
  import org.jdom.Attribute;
  import org.jdom.JDOMException;
  
  import org.apache.slide.common.Domain;
  import org.apache.slide.common.SlideToken;
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.content.NodeProperty;
  import org.apache.slide.content.NodeRevisionDescriptor;
  import org.apache.slide.content.NodeRevisionDescriptors;
  
  
  /**
   * Helper class for handling WebDAV resources.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
   */
  
  public class PropertyHelper extends AbstractWebdavHelper {
      
      // supported live-properties (resource-kind -> set-of-live-props)
      protected static Map supportedLiveProperties = new HashMap();
          
      // protected properties
      protected static Set protectedProperties = new HashSet();
          
      // computed properties
      protected static Set computedProperties = new HashSet();
      
      
      // initialization
      static {
          Set s = null;
          
          // Computed properties
  //        computedProperties.add( P_LOCKDISCOVERY );
  //        computedProperties.add( P_SUPPORTEDLOCK );
  //        computedProperties.add( P_<some_acl_methods> );
          computedProperties.add( P_SUCCESSOR_SET );
          computedProperties.add( P_CHECKOUT_SET );
          computedProperties.add( P_ROOT_VERSION );
          computedProperties.add( P_VERSION_HISTORY );
          computedProperties.add( P_WORKSPACE_CHECKOUT_SET );
          computedProperties.add( P_VERSION_CONTROLLED_CONFIGURATION );
          computedProperties.add( P_BASELINE_CONTROLLED_COLLECTION_SET );
          computedProperties.add( P_ACTIVITY_VERSION_SET );
          computedProperties.add( P_ACTIVITY_CHECKOUT_SET );
          computedProperties.add( P_CURRENT_WORKSPACE_SET );
          computedProperties.add( P_ECLIPSED_SET );
          computedProperties.add( P_SUPPORTED_LIVE_PROPERTY_SET ); //"protected" in 
spec but too long
          computedProperties.add( P_SUPPORTED_METHOD_SET );        //"protected" in 
spec but too long
          computedProperties.add( P_SUPPORTED_REPORT_SET );        //"protected" in 
spec but too long
          
          // Protected properties
  //        protectedProperties.add( P_SUPPORTED_METHOD_SET );
  //        protectedProperties.add( P_SUPPORTED_LIVE_PROPERTY_SET );
  //        protectedProperties.add( P_SUPPORTED_REPORT_SET );
          protectedProperties.add( P_CHECKED_IN );
          protectedProperties.add( P_CHECKED_OUT );
          protectedProperties.add( P_PREDECESSOR_SET );
          protectedProperties.add( P_VERSION_NAME );
          protectedProperties.add( P_VERSION_SET );
          protectedProperties.add( P_WORKSPACE );
          protectedProperties.add( P_LABEL_NAME_SET );
          protectedProperties.add( P_AUTO_UPDATE );
          protectedProperties.add( P_BASELINE_CONTROLLED_COLLECTION );
          protectedProperties.add( P_BASELINE_COLLECTION );
          protectedProperties.add( P_SUBBASELINE_SET );
          protectedProperties.add( P_VERSION_CONTROLLED_BINDING_SET );
          
          
          // DeltaV-Compliant Unmapped URL
          supportedLiveProperties.put(
              K_DELTAV_COMPLIANT_UNMAPPED_URL, Collections.EMPTY_SET );
          
          // DeltaV-Compliant Resource
          s = new HashSet();
          s.add( P_CREATIONDATE );
          s.add( P_DISPLAYNAME );
          s.add( P_GETCONTENTLANGUAGE );
          s.add( P_GETCONTENTLENGTH );
          s.add( P_GETCONTENTTYPE );
          s.add( P_GETETAG );
          s.add( P_GETLASTMODIFIED );
          s.add( P_RESOURCETYPE );
          s.add( P_SOURCE );
          if( isSupportedFeature(F_LOCKING) ) {
              s.add( P_LOCKDISCOVERY );
              s.add( P_SUPPORTEDLOCK );
          }
          if( isSupportedFeature(F_ACCESS_CONTROL) ) {
              s.add( P_ALTERNATE_URI_SET );
              s.add( P_OWNER );
              s.add( P_SUPPORTED_PRIVILEGE_SET );
              s.add( P_CURRENT_USER_PRIVILEGE_SET );
              s.add( P_ACL );
              s.add( P_ACL_SEMANTICS );
              s.add( P_PRINCIPAL_COLLECTION_SET );
          }
          if( isSupportedFeature(F_VERSION_CONTROL) ) {
              s.add( P_COMMENT );
              s.add( P_CREATOR_DISPLAYNAME );
              s.add( P_SUPPORTED_METHOD_SET );
              s.add( P_SUPPORTED_LIVE_PROPERTY_SET );
              s.add( P_SUPPORTED_REPORT_SET );
          }
          if( isSupportedFeature(F_WORKSPACE) )
              s.add( P_WORKSPACE );
          if( isSupportedFeature(F_BASELINE) )
              s.add( P_VERSION_CONTROLLED_CONFIGURATION );
          supportedLiveProperties.put( K_DELTAV_COMPLIANT, s );
          
          // DeltaV-Compliant Collection
          s = new HashSet();
          s.addAll( (Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT) );
          supportedLiveProperties.put( K_DELTAV_COMPLIANT_COLLECTION, s );
                  
          // Versionable Resource
          s = new HashSet();
          s.addAll( (Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT) );
          supportedLiveProperties.put( K_VERSIONABLE, s );
          
          // Version-Controlled Resource
          s = new HashSet();
          if( isSupportedFeature(F_VERSION_CONTROL) )
              s.add( P_AUTO_VERSION );
          if( isSupportedFeature(F_VERSION_HISTORY) )
              s.add( P_VERSION_HISTORY );
          s.addAll( (Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT) );
          supportedLiveProperties.put( K_VERSION_CONTROLLED, s );
          
          // Version
          s = new HashSet();
          if( isSupportedFeature(F_VERSION_CONTROL) ) {
              s.add( P_PREDECESSOR_SET );
              s.add( P_SUCCESSOR_SET );
              s.add( P_CHECKOUT_SET );
              s.add( P_VERSION_NAME );
          }
          if( isSupportedFeature(F_CHECKOUT_IN_PLACE) || 
isSupportedFeature(F_WORKING_RESOURCE) ) {
              s.add( P_CHECKOUT_FORK );
              s.add( P_CHECKIN_FORK );
          }
          if( isSupportedFeature(F_VERSION_HISTORY) )
              s.add( P_VERSION_HISTORY );
          if( isSupportedFeature(F_LABEL) )
              s.add( P_LABEL_NAME_SET );
          if( isSupportedFeature(F_ACTIVITY) )
              s.add( P_ACTIVITY_SET);
          s.addAll( (Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT) );
          supportedLiveProperties.put( K_VERSION, s );
          
          // Checked-In Version-Controlled Resource
          s = new HashSet();
          if( isSupportedFeature(F_VERSION_CONTROL) )
              s.add( P_CHECKED_IN );
          s.addAll( (Set)supportedLiveProperties.get(K_VERSION_CONTROLLED) );
          supportedLiveProperties.put( K_CHECKED_IN_VERSION_CONTROLLED, s );
          
          // Checked-Out Resource
          s = new HashSet();
          if( isSupportedFeature(F_VERSION_CONTROL) ) {
              s.add( P_CHECKED_OUT );
              s.add( P_PREDECESSOR_SET );
          }
          if( isSupportedFeature(F_CHECKOUT_IN_PLACE) || 
isSupportedFeature(F_WORKING_RESOURCE) ) {
              s.add( P_CHECKOUT_FORK );
              s.add( P_CHECKIN_FORK );
          }
          if( isSupportedFeature(F_MERGE) ) {
              s.add( P_MERGE_SET );
              s.add( P_AUTO_MERGE_SET );
          }
          if( isSupportedFeature(F_ACTIVITY) ) {
              s.add( P_UNRESERVED );
              s.add( P_ACTIVITY_SET );
          }
          supportedLiveProperties.put( K_CHECKED_OUT, s );
          
          // Checked-Out Version-Controlled Resource
          if( isSupportedFeature(F_CHECKOUT_IN_PLACE) ) {
              s = new HashSet();
              s.addAll( (Set)supportedLiveProperties.get(K_VERSION_CONTROLLED) );
              s.addAll( (Set)supportedLiveProperties.get(K_CHECKED_OUT) );
              supportedLiveProperties.put( K_CHECKED_OUT_VERSION_CONTROLLED, s );
          }
          
          // Working Resource
          if( isSupportedFeature(F_WORKING_RESOURCE) ) {
              s = new HashSet();
              s.add( P_AUTO_UPDATE );
              s.addAll( (Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT) );
              s.addAll( (Set)supportedLiveProperties.get(K_CHECKED_OUT) );
              supportedLiveProperties.put( K_WORKING, s );
          }
          
          // Version History
          if( isSupportedFeature(F_VERSION_HISTORY) ) {
              s = new HashSet();
              s.add( P_VERSION_SET );
              s.add( P_ROOT_VERSION );
              s.addAll( (Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT) );
              supportedLiveProperties.put( K_VERSION_HISTORY, s );
          }
          
          // Workspace
          if( isSupportedFeature(F_WORKSPACE) ) {
              s = new HashSet();
              s.add( P_WORKSPACE_CHECKOUT_SET );
              if( isSupportedFeature(F_BASELINE) )
                  s.add( P_BASELINE_CONTROLLED_COLLECTION_SET );
              if( isSupportedFeature(F_ACTIVITY) )
                  s.add( P_CURRENT_ACTIVITY_SET );
              s.addAll( 
(Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT_COLLECTION) );
              supportedLiveProperties.put( K_WORKSPACE, s );
          }
          
          // Activity
          if( isSupportedFeature(F_ACTIVITY) ) {
              s = new HashSet();
              s.add( P_ACTIVITY_VERSION_SET );
              s.add( P_ACTIVITY_CHECKOUT_SET );
              s.add( P_SUBACTIVITY_SET );
              s.add( P_CURRENT_WORKSPACE_SET );
              s.addAll( (Set)supportedLiveProperties.get(K_DELTAV_COMPLIANT) );
              supportedLiveProperties.put( K_ACTIVITY, s );
          }
          
          // Version-Controlled Collection **NOT YET IMPLEMENTED**
          if( isSupportedFeature(F_VERSION_CONTROLLED_COLLECTION) ) {
              s = new HashSet();
              s.add( P_ECLIPSED_SET );
              s.addAll( (Set)supportedLiveProperties.get(K_VERSION_CONTROLLED) );
              supportedLiveProperties.put(
                  K_VERSION_CONTROLLED_COLLECTION, s );
          }
          
          // Collection Version
          if( isSupportedFeature(F_VERSION_CONTROLLED_COLLECTION) ) {
              s = new HashSet();
              s.add( P_VERSION_CONTROLLED_BINDING_SET );
              s.addAll( (Set)supportedLiveProperties.get(K_VERSION) );
              supportedLiveProperties.put( K_COLLECTION_VERSION, s );
          }
          
          // Version-Controlled Configuration
          if( isSupportedFeature(F_BASELINE) ) {
              s = new HashSet();
              s.add( P_BASELINE_CONTROLLED_COLLECTION );
              s.addAll( (Set)supportedLiveProperties.get(K_VERSION_CONTROLLED) );
              supportedLiveProperties.put(
                  K_VERSION_CONTROLLED_CONFIGURATION, s );
          }
          
          // Baseline
          if( isSupportedFeature(F_BASELINE) ) {
              s = new HashSet();
              s.add( P_BASELINE_COLLECTION );
              s.add( P_SUBBASELINE_SET );
              s.addAll( (Set)supportedLiveProperties.get(K_VERSION) );
              supportedLiveProperties.put( K_BASELINE, s );
          }
          
          // Checked-out Version-Controlled Configuration
          if( isSupportedFeature(F_BASELINE) ) {
              s = new HashSet();
              s.add( P_SUBBASELINE_SET );
              s.addAll( 
(Set)supportedLiveProperties.get(K_VERSION_CONTROLLED_CONFIGURATION) );
              supportedLiveProperties.put(
                  K_CHECKED_OUT_VERSION_CONTROLLED_CONFIGURATION, s );
          }
      }
      
      /**
       * Factory method.
       */
      public static PropertyHelper
      getPropertyHelper( SlideToken sToken, NamespaceAccessToken nsaToken) {
          return new PropertyHelper( sToken, nsaToken );
      }
      
      /**
       * Return true if the specified property is protected.
       */
      public static boolean isProtected( String propName ) {
          return( protectedProperties.contains(propName) ||
                  computedProperties.contains(propName) );
      }
      
      /**
       * Return true if the specified property is computed.
       */
      public static boolean isComputed( String propName ) {
          return( computedProperties.contains(propName) );
      }
      
      
      private MethodHelper mhelp = null;
      private ReportHelper rhelp = null;
      
      /**
       * Protected contructor
       */
      protected PropertyHelper( SlideToken sToken, NamespaceAccessToken nsaToken ) {
          super( sToken, nsaToken );
          this.mhelp = MethodHelper.getMethodHelper( sToken, nsaToken );
          this.rhelp = ReportHelper.getReportHelper( sToken, nsaToken );
      }
      
      /**
       * Create initial default properties to be stored for the specified
       * resource kind.
       * The result set does not contain transient properties.
       * @post result != null
       * @return a list of initial non-transient properties (empty list if none)
       */
      public List createInitialProperties( String resourceKind ) {
          
          Set sp = (Set)supportedLiveProperties.get( resourceKind );
          List result = null;
          
          if( sp == null )
              result = Collections.EMPTY_LIST;
          else {
              result = new ArrayList();
              Iterator i = sp.iterator();
              while( i.hasNext() ) {
                  String propName = (String)i.next();
                  if( computedProperties.contains(propName) )
                      continue;
                  Object pvalue = createDefaultValue( propName, resourceKind );
                  result.add( new NodeProperty(
                      propName, pvalue, protectedProperties.contains(propName)) );
              }
          }
          return result;
      }
  
      /**
       * Create a default value for the specified property name and resource
       * kind
       */
      Object createDefaultValue( String propName, String resourceKind ) {
          
          String result = "";
          
          if( P_RESOURCETYPE.equals(propName) && 
K_VERSION_HISTORY.equals(resourceKind) ) {
              StringBuffer rtvv = new StringBuffer();
              try {
                  rtvv.append(
                      xmlOut.outputString(new Element(E_VERSION_HISTORY, 
defNamespace)) );
                  rtvv.append(
                      xmlOut.outputString(new Element(E_COLLECTION, defNamespace)) );
              }
              catch( Exception x ) {
                  x.printStackTrace();
              }
              result = rtvv.toString();
          }
          else if( P_SUPPORTED_METHOD_SET.equals(propName) ) {
              Iterator i = (mhelp.getSupportedMethods(resourceKind)).iterator();
              StringBuffer smsv = new StringBuffer();
              while( i.hasNext() ) {
                  String m = (String) i.next();
                  Element sm = new Element( E_SUPPORTED_METHOD, defNamespace );
                  Attribute na = new Attribute( A_NAME, m, defNamespace );
                  sm.addAttribute( na );
                  try {
                      smsv.append( xmlOut.outputString(sm) );
                  }
                  catch( Exception x ) { x.printStackTrace(); }
              }
              result = smsv.toString();
          }
          else if( P_SUPPORTED_LIVE_PROPERTY_SET.equals(propName) ) {
              Iterator i = ((Set)supportedLiveProperties.get(resourceKind)).iterator();
              StringBuffer spsv = new StringBuffer();
              while( i.hasNext() ) {
                  String p = (String) i.next();
                  Element sp = new Element( E_SUPPORTED_LIVE_PROPERTY, defNamespace );
                  Element na = new Element( E_NAME, defNamespace );
                  na.addContent( p );
                  sp.addContent( na );
                  try {
                      spsv.append( xmlOut.outputString(sp) );
                  }
                  catch( Exception x ) { x.printStackTrace(); }
              }
              result = spsv.toString();
          }
          else if( P_SUPPORTED_REPORT_SET.equals(propName) ) {
              Iterator i = rhelp.getSupportedReports().iterator();
              StringBuffer srsv = new StringBuffer();
              while( i.hasNext() ) {
                  String r = (String) i.next();
                  Element sr = new Element( E_SUPPORTED_REPORT, defNamespace );
                  Element na = new Element( E_NAME, defNamespace );
                  na.addContent( r );
                  sr.addContent( na );
                  try {
                      srsv.append( xmlOut.outputString(sr) );
                  }
                  catch( Exception x ) { x.printStackTrace(); }
              }
              result = srsv.toString();
          }
          else if( P_AUTO_VERSION.equals(propName) ) {
              Element avv = null;
              String avconf = nsaToken.getNamespaceConfig().getAutoVersion();
              
              if( E_CHECKOUT_CHECKIN.equals(avconf) ) {
                  avv = new Element( E_CHECKOUT_CHECKIN, defNamespace );
              }
              else if( E_CHECKOUT_UNLOCKED_CHECKIN.equals(avconf) ) {
                  avv = new Element( E_CHECKOUT_UNLOCKED_CHECKIN, defNamespace );
              }
              else if( E_CHECKOUT.equals(avconf) ) {
                  avv = new Element( E_CHECKOUT, defNamespace );
              }
              else if( E_LOCKED_CHECKOUT.equals(avconf) ) {
                  avv = new Element( E_LOCKED_CHECKOUT, defNamespace );
              }
              else {
                  Domain.warn( "Auto-version not configured properly; using "
                               +E_CHECKOUT_CHECKIN );
                  avv = new Element( E_CHECKOUT_CHECKIN, defNamespace );
              }
              
              try {
                  result = xmlOut.outputString( avv );
              }
              catch( Exception x ) {
                  x.printStackTrace();
              }
          }
          else if( P_CHECKOUT_FORK.equals(propName) ) {
              Element cfv = null;
              String cfconf = nsaToken.getNamespaceConfig().getCheckoutFork();
              
              if( E_FORBIDDEN.equals(cfconf) ) {
                  cfv = new Element( E_FORBIDDEN, defNamespace );
              }
              else if( E_DISCOURAGED.equals(cfconf) ) {
                  cfv = new Element( E_DISCOURAGED, defNamespace );
              }
              else {
                  Domain.warn( "Checkout-fork not configured properly; using "
                               +E_FORBIDDEN );
                  cfv = new Element( E_FORBIDDEN, defNamespace );
              }
              
              try {
                  result = xmlOut.outputString( cfv );
              }
              catch( Exception x ) {
                  x.printStackTrace();
              }
          }
          else if( P_CHECKIN_FORK.equals(propName) ) {
              Element cfv = null;
              String cfconf = nsaToken.getNamespaceConfig().getCheckinFork();
              
              if( E_FORBIDDEN.equals(cfconf) ) {
                  cfv = new Element( E_FORBIDDEN, defNamespace );
              }
              else if( E_DISCOURAGED.equals(cfconf) ) {
                  cfv = new Element( E_DISCOURAGED, defNamespace );
              }
              else {
                  Domain.warn( "Checkin-fork not configured properly; using "
                               +E_FORBIDDEN );
                  cfv = new Element( E_FORBIDDEN, defNamespace );
              }
              
              try {
                  result = xmlOut.outputString( cfv );
              }
              catch( Exception x ) {
                  x.printStackTrace();
              }
          }
  
          return result;
      }
      
      /**
       * Create href value.
       */
      public Object createHrefValue( String uri ) {
          String result = "";
          
          Element href = new Element( E_HREF, defNamespace );
          href.addContent( uri );
          try {
              result = xmlOut.outputString( href );
          }
          catch( Exception x ) {
              x.printStackTrace();
          }
          
          return result;
      }
      
      /**
       * Create href set value.
       */
      public Object createHrefSetValue( String rootElement, List uriList ) {
          String result = "";
          
          Element root = new Element( rootElement, defNamespace );
          Iterator i = uriList.iterator();
          
          while( i.hasNext() ) {
              Element href = new Element( E_HREF, defNamespace );
              href.addContent( (String)i.next() );
              root.addContent( href );
          }
          try {
              result = xmlOut.outputString( root );
          }
          catch( Exception x ) {
              x.printStackTrace();
          }
          
          return result;
      }
      
      /**
       * Parse an XML-Valued property value.
       */
      public Element parsePropertyValue( String propValue ) throws JDOMException {
          Document d = xmlBuilder.build( new StringReader(propValue) );
          return d.getRootElement();
      }
  
      /**
       *
       */
      public static void main(String[] args) {
          Iterator i, j;
          
          i = supportedFeatures.iterator();
          System.out.println("\nSupported features");
          System.out.println(  "------------------");
          while( i.hasNext() )
              System.out.println("- "+i.next());
          
          i = supportedLiveProperties.keySet().iterator();
          System.out.println("\nSupported live properties");
          System.out.println(  "-------------------------");
          while( i.hasNext() ) {
              String k = (String)i.next();
              j = ((Set)supportedLiveProperties.get(k)).iterator();
              System.out.println(k+":");
              while( j.hasNext() )
                  System.out.println("- "+j.next());
          }
          
          i = protectedProperties.iterator();
          System.out.println("\nProtected properties");
          System.out.println(  "--------------------");
          while( i.hasNext() )
              System.out.println("- "+i.next());
          
          i = computedProperties.iterator();
          System.out.println("\nComputed properties");
          System.out.println(  "-------------------");
          while( i.hasNext() )
              System.out.println("- "+i.next());
      }
  }
  
  
  
  
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/MethodHelper.java
  
  Index: MethodHelper.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/MethodHelper.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  import java.io.*;
  import java.util.*;
  
  import org.jdom.output.XMLOutputter;
  import org.jdom.Element;
  import org.jdom.Attribute;
  import org.jdom.Namespace;
  
  import org.apache.slide.common.Domain;
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.common.SlideToken;
  import org.apache.slide.content.NodeProperty;
  import org.apache.slide.content.NodeRevisionDescriptor;
  import org.apache.slide.content.NodeRevisionDescriptors;
  
  
  /**
   * Helper class for handling method resources.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
   */
  
  public class MethodHelper extends AbstractWebdavHelper {
      
      // supported methods (resource-kind -> set-of-methods)
      protected static Map supportedMethods = new HashMap();
          
      // initialization
      static {
          Set s = null;
          
          // DeltaV-Compliant Unmapped URL
          s = new HashSet();
          s.add( M_PUT );
          s.add( M_MKCOL );
          if( isSupportedFeature(F_VERSION_CONTROL) )
              s.add( M_VERSION_CONTROL );
          if( isSupportedFeature(F_WORKSPACE) )
              s.add( M_MKWORKSPACE );
          supportedMethods.put( K_DELTAV_COMPLIANT_UNMAPPED_URL, s );
          
          // DeltaV-Compliant Resource
          s = new HashSet();
          s.add( M_CONNECT );
          s.add( M_COPY );
          s.add( M_DELETE );
          s.add( M_GET );
          s.add( M_HEAD );
          s.add( M_MOVE );
          s.add( M_OPTIONS );
          s.add( M_POST );
          s.add( M_PROPFIND );
          s.add( M_PROPPATCH );
          s.add( M_PUT );
          s.add( M_TRACE );
          if( isSupportedFeature(F_LOCKING) ) {
              s.add( M_LOCK );
              s.add( M_UNLOCK );
          }
          if( isSupportedFeature(F_ACCESS_CONTROL) )
              s.add( M_ACL );
          if( isSupportedFeature(F_ACCESS_CONTROL) || 
isSupportedFeature(F_VERSION_CONTROL) )
              s.add( M_REPORT );
          if( isSupportedFeature(F_SEARCHING_AND_LOCATING) ) {
              s.add( M_SEARCH );
          }
          supportedMethods.put( K_DELTAV_COMPLIANT, s );
          
          // DeltaV-Compliant Collection
          s = new HashSet();
          if( isSupportedFeature(F_BASELINE) )
              s.add( M_BASELINE_CONTROL );
          s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT) );
          supportedMethods.put( K_DELTAV_COMPLIANT_COLLECTION, s );
                  
          // Versionable Resource
          s = new HashSet();
          if( isSupportedFeature(F_VERSION_CONTROL) )
              s.add( M_VERSION_CONTROL );
          s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT) );
          supportedMethods.put( K_VERSIONABLE, s );
          
          // Version-Controlled Resource
          s = new HashSet();
          if( isSupportedFeature(F_VERSION_CONTROL) )
              s.add( M_VERSION_CONTROL );
          if( isSupportedFeature(F_MERGE) )
              s.add( M_MERGE );
          s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT) );
          supportedMethods.put( K_VERSION_CONTROLLED, s );
          
          // Version
          s = new HashSet();
          if( isSupportedFeature(F_LABEL) )
              s.add( M_LABEL );
          if( isSupportedFeature(F_WORKING_RESOURCE) )
              s.add( M_CHECKOUT );
          s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT) );
          supportedMethods.put( K_VERSION, s );
          
          // Checked-In Version-Controlled Resource
          s = new HashSet();
          if( isSupportedFeature(F_CHECKOUT_IN_PLACE) )
              s.add( M_CHECKOUT );
          if( isSupportedFeature(F_UPDATE) )
              s.add( M_UPDATE );
          s.addAll( (Set)supportedMethods.get(K_VERSION_CONTROLLED) );
          supportedMethods.put( K_CHECKED_IN_VERSION_CONTROLLED, s );
          
          // Checked-Out Resource
          s = new HashSet();
          if( isSupportedFeature(F_CHECKOUT_IN_PLACE) || 
isSupportedFeature(F_WORKING_RESOURCE) )
              s.add( M_CHECKIN );
          s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT) );
          supportedMethods.put( K_CHECKED_OUT, s );
          
          // Checked-Out Version-Controlled Resource
          if( isSupportedFeature(F_CHECKOUT_IN_PLACE) ) {
              s = new HashSet();
              s.add( M_UNCHECKOUT );
              s.addAll( (Set)supportedMethods.get(K_VERSION_CONTROLLED) );
              s.addAll( (Set)supportedMethods.get(K_CHECKED_OUT) );
              supportedMethods.put( K_CHECKED_OUT_VERSION_CONTROLLED, s );
          }
          
          // Working Resource
          if( isSupportedFeature(F_WORKING_RESOURCE) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_CHECKED_OUT) );
              supportedMethods.put( K_WORKING, s );
          }
          
          // Version History
          if( isSupportedFeature(F_VERSION_HISTORY) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT) );
              supportedMethods.put( K_VERSION_HISTORY, s );
          }
          
          // Workspace
          if( isSupportedFeature(F_WORKSPACE) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT_COLLECTION) );
              supportedMethods.put( K_WORKSPACE, s );
          }
          
          // Activity
          if( isSupportedFeature(F_ACTIVITY) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_DELTAV_COMPLIANT) );
              supportedMethods.put( K_ACTIVITY, s );
          }
          
          // Version-Controlled Collection
          if( isSupportedFeature(F_VERSION_CONTROLLED_COLLECTION) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_VERSION_CONTROLLED) );
              supportedMethods.put(
                  K_VERSION_CONTROLLED_COLLECTION, s );
          }
          
          // Collection Version
          if( isSupportedFeature(F_VERSION_CONTROLLED_COLLECTION) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_VERSION) );
              supportedMethods.put( K_COLLECTION_VERSION, s );
          }
          
          // Version-Controlled Configuration
          if( isSupportedFeature(F_BASELINE) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_VERSION_CONTROLLED) );
              supportedMethods.put(
                  K_VERSION_CONTROLLED_CONFIGURATION, s );
          }
          
          // Baseline
          if( isSupportedFeature(F_BASELINE) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_VERSION) );
              supportedMethods.put( K_BASELINE, s );
          }
          
          // Checked-out Version-Controlled Configuration
          if( isSupportedFeature(F_BASELINE) ) {
              s = new HashSet();
              s.addAll( (Set)supportedMethods.get(K_VERSION_CONTROLLED_CONFIGURATION) 
);
              supportedMethods.put(
                  K_CHECKED_OUT_VERSION_CONTROLLED_CONFIGURATION, s );
          }
      }
      
      /**
       * Factory method.
       */
      public static MethodHelper
      getMethodHelper( SlideToken sToken, NamespaceAccessToken nsaToken) {
          
          return new MethodHelper( sToken, nsaToken );
      }
      
      
      /**
       * Protected contructor
       */
      protected MethodHelper( SlideToken sToken, NamespaceAccessToken nsaToken ) {
          super( sToken, nsaToken );
      }
      
      /**
       * Return the set of supported methods for the specified resource kind.
       */
      public Set getSupportedMethods( String resourceKind ) {
          return (Set)supportedMethods.get( resourceKind );
      }
  
      /**
       * Return true if the specified method is supported for the specified resource 
kind.
       */
      public boolean isSupportedMethod( String method, String resourceKind ) {
          return ((Set)supportedMethods.get(resourceKind)).contains( method );
      }
      
      /**
       *
       */
      public static void main(String[] args) {
          Iterator i, j;
          
          i = supportedFeatures.iterator();
          System.out.println("\nSupported features");
          System.out.println(  "------------------");
          while( i.hasNext() )
              System.out.println("- "+i.next());
          
          i = supportedMethods.keySet().iterator();
          System.out.println("\nSupported methods");
          System.out.println(  "-----------------");
          while( i.hasNext() ) {
              String k = (String)i.next();
              j = ((Set)supportedMethods.get(k)).iterator();
              System.out.println(k+":");
              while( j.hasNext() )
                  System.out.println("- "+j.next());
          }
      }
  }
  
  
  
  
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/HistoryPathHandler.java
  
  Index: HistoryPathHandler.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/HistoryPathHandler.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  import java.util.*;
  
  import org.apache.slide.common.SlideToken;
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.common.ServiceAccessException;
  import org.apache.slide.structure.ObjectNotFoundException;
  import org.apache.slide.structure.LinkedObjectNotFoundException;
  import org.apache.slide.content.Content;
  import org.apache.slide.content.NodeProperty;
  import org.apache.slide.content.NodeRevisionDescriptors;
  import org.apache.slide.content.NodeRevisionDescriptor;
  import org.apache.slide.content.RevisionNotFoundException;
  import org.apache.slide.content.RevisionDescriptorNotFoundException;
  import org.apache.slide.lock.ObjectLockedException;
  import org.apache.slide.security.AccessDeniedException;
  
  //  throws ObjectNotFoundException, AccessDeniedException,
  //  LinkedObjectNotFoundException, ServiceAccessException,
  //  ObjectLockedException {
  
  
  public class HistoryPathHandler extends UriHandler {
      
      /**
       * Factory method.
       */
      public static UriHandler
      getHistoryPathHandler( NamespaceAccessToken nsaToken ) {
          
          String nsName = nsaToken.getName();
          UriHandler result = (UriHandler)hpathHandlers.get( nsName );
          
          if( result == null ) {
              String hpath = nsaToken.getNamespaceConfig().getHistoryPath();
              if( hpath == null || hpath.length() == 0 )
                  throw new IllegalStateException(
                      "No history path defined in namespace "+nsName+"; either "+
                      "define it in domain.xml or disable versioning in 
slide.properties"
                  );
              result = new HistoryPathHandler( nsName, hpath );
              hpathHandlers.put( nsName, result );
          }
          return result;
      }
      
      
      /**
       * Protected constructor
       */
      protected HistoryPathHandler( String nsName, String uri ) {
          super( nsName, uri );
      }
      
      /**
       * TODO: methods to resolve parametrized history paths
       */
  }
  
  
  
  
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/DaslConstants.java
  
  Index: DaslConstants.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/DaslConstants.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  /**
   * DASL constants.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
   */
  public interface DaslConstants extends WebdavConstants {
  
      /** Features */
      String F_SEARCHING_AND_LOCATING         = "searching-and-locating";
      
      /** Live Properties */
  
      /** Methods */
      String M_SEARCH                          = "SEARCH";
  
      /** Reposrts */
  
      /** XML Elements */
  
      /** XML Attributes */
      
      /** Resource Kinds */
  }
  
  
  
  
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/AclConstants.java
  
  Index: AclConstants.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/AclConstants.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  /**
   * ACL constants.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
   */
  public interface AclConstants extends WebdavConstants {
      
      /** Resource Kinds */
      String K_PRINCIPAL                       = "Principal";
  
      /** Features */
      String F_ACCESS_CONTROL                  = "access-control";
      
      /** Live Properties */
      String P_ALTERNATE_URI_SET               = "alternate-URI-set";
      String P_OWNER                           = "owner";
      String P_SUPPORTED_PRIVILEGE_SET         = "supported-privilege-set";
      String P_CURRENT_USER_PRIVILEGE_SET      = "current-user-privilege-set";
      String P_ACL                             = "acl";
      String P_ACL_SEMANTICS                   = "acl-semantics";
      String P_PRINCIPAL_COLLECTION_SET        = "principal-collection-set";
  
      /** Methods */
      String M_ACL                             = "ACL";
  
      /** Reposrts */
      String R_ACL_PRINCIPAL_PROPS             = "acl-principal-props";
      String R_PRINCIPAL_MATCH                 = "principal-match";
      String R_PRINCIPAL_PROPERTY_SEARCH       = "principal-property-search";
      String R_PRINCIPAL_SEARCH_PROPERTY_SET   = "principal-search-property-set";
  
      /** XML Elements */
  
      /** XML Attributes */
  }
  
  
  
  
  1.1                  
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/AbstractWebdavHelper.java
  
  Index: AbstractWebdavHelper.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/AbstractWebdavHelper.java,v
 1.1 2002/02/26 11:52:16 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/26 11:52:16 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.util;
  
  import java.util.*;
  
  import org.jdom.Element;
  import org.jdom.input.SAXBuilder;
  import org.jdom.output.XMLOutputter;
  
  import org.apache.slide.common.SlideToken;
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.content.NodeRevisionDescriptor;
  
  
  /**
   * Helper class for handling report resources.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Nevermann</a>
   */
  
  public class AbstractWebdavHelper
  implements AclConstants, DeltavConstants, DaslConstants {
      
      // Default JDOM namespace
  //    protected static org.jdom.Namespace defNamespace = Namespace.getNamespace(
  //        DEFAULT_PREFIX, DEFAULT_NAMESPACE );
      protected static org.jdom.Namespace defNamespace = null;
      
      // an XML outputter
      protected static XMLOutputter xmlOut = new XMLOutputter();
      
      // an XML parser
      protected static SAXBuilder xmlBuilder = new SAXBuilder();
          
      // supported reports
      protected static Set supportedFeatures = new HashSet();
                  
      // static initialization
      static {
          supportedFeatures.add( F_LOCKING );
          supportedFeatures.add( F_ACCESS_CONTROL );
          supportedFeatures.add( F_SEARCHING_AND_LOCATING );
          supportedFeatures.add( F_VERSION_CONTROL );
          supportedFeatures.add( F_VERSION_HISTORY );
          supportedFeatures.add( F_CHECKOUT_IN_PLACE );
          supportedFeatures.add( F_WORKSPACE );
          supportedFeatures.add( F_WORKING_RESOURCE );
          supportedFeatures.add( F_LABEL );
          supportedFeatures.add( F_UPDATE );
      }
      
      /**
       *
       */
      public static Set getSupportedFeatures() {
          return supportedFeatures;
      }
      
      /**
       *
       */
      public static boolean isSupportedFeature( String feature ) {
          return supportedFeatures.contains( feature );
      }
              
      
      
      // the Slide token
      protected SlideToken sToken = null;
      
      // the namespace access token
      protected NamespaceAccessToken nsaToken = null;
      
      /**
       * Protected contructor
       */
      protected AbstractWebdavHelper( SlideToken sToken, NamespaceAccessToken nsaToken 
) {
          this.sToken = sToken;
          this.nsaToken = nsaToken;
      }
  
      /**
       * Determine the DeltaV-kind of resource.
       * @param nrd the associated NodeRevisionDescriptor
       * @return the kind of resource
       * @see DeltavConstants
       */
      public String determineResourceKind( NodeRevisionDescriptor nrd ) {
          String result = null;
          
          if( nrd == null ) {
              result = K_DELTAV_COMPLIANT_UNMAPPED_URL;
          }
          else if( nrd.exists(P_CHECKED_IN) ) {
              result = K_CHECKED_IN_VERSION_CONTROLLED;
          }
          else if( nrd.exists(P_CHECKED_OUT) ) {
              result = K_CHECKED_OUT_VERSION_CONTROLLED;
          }
          else if( nrd.exists(P_VERSION_NAME) ) {
              result = K_VERSION;
          }
          else if( nrd.exists(P_WORKSPACE_CHECKOUT_SET) ) {
              result = K_WORKSPACE;
          }
          else if( nrd.exists(P_AUTO_UPDATE) ) {
              result = K_WORKING;
          }
          else if( nrd.propertyValueContains(P_RESOURCETYPE, E_VERSION_HISTORY) ) {
              result = K_VERSION_HISTORY;
          }
          else if( nrd.propertyValueContains(P_RESOURCETYPE, E_PRINCIPAL) ) {
              result = K_PRINCIPAL;
          }
          else if( nrd.propertyValueContains(P_RESOURCETYPE, E_COLLECTION) ) {
              result = K_DELTAV_COMPLIANT_COLLECTION;
          }
          else {
              result = K_VERSIONABLE;
          }
  
          return result;
      }
  }
  
  
  
  

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

Reply via email to