You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by pn...@apache.org on 2002/02/28 13:37:46 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util AbstractWebdavHelper.java PropertyHelper.java
pnever 02/02/28 04:37:46
Modified: src/webdav/server/org/apache/slide/webdav/util
AbstractWebdavHelper.java PropertyHelper.java
Log:
Moved some stuff to new AbstractResourceKind
Revision Changes Path
1.2 +3 -78 jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/AbstractWebdavHelper.java
Index: AbstractWebdavHelper.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/AbstractWebdavHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractWebdavHelper.java 26 Feb 2002 11:52:16 -0000 1.1
+++ AbstractWebdavHelper.java 28 Feb 2002 12:37:46 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $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 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/AbstractWebdavHelper.java,v 1.2 2002/02/28 12:37:46 pnever Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/02/28 12:37:46 $
*
* ====================================================================
*
@@ -71,7 +71,6 @@
import org.apache.slide.common.SlideToken;
import org.apache.slide.common.NamespaceAccessToken;
-import org.apache.slide.content.NodeRevisionDescriptor;
/**
@@ -94,37 +93,6 @@
// 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
@@ -139,49 +107,6 @@
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;
}
}
1.3 +14 -322 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PropertyHelper.java 26 Feb 2002 13:27:30 -0000 1.2
+++ PropertyHelper.java 28 Feb 2002 12:37:46 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v 1.2 2002/02/26 13:27:30 pnever Exp $
- * $Revision: 1.2 $
- * $Date: 2002/02/26 13:27:30 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v 1.3 2002/02/28 12:37:46 pnever Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/02/28 12:37:46 $
*
* ====================================================================
*
@@ -77,6 +77,7 @@
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
+import org.apache.slide.webdav.util.resourcekind.*;
/**
@@ -87,259 +88,6 @@
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.
*/
@@ -348,32 +96,12 @@
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 );
}
/**
@@ -383,9 +111,9 @@
* @post result != null
* @return a list of initial non-transient properties (empty list if none)
*/
- public List createInitialProperties( String resourceKind ) {
+ public List createInitialProperties( ResourceKind resourceKind ) {
- Set sp = (Set)supportedLiveProperties.get( resourceKind );
+ Set sp = resourceKind.getSupportedLiveProperties();
List result = null;
if( sp == null )
@@ -395,11 +123,11 @@
Iterator i = sp.iterator();
while( i.hasNext() ) {
String propName = (String)i.next();
- if( computedProperties.contains(propName) )
+ if( AbstractResourceKind.isComputedProperty(propName) )
continue;
Object pvalue = createDefaultValue( propName, resourceKind );
- result.add( new NodeProperty(
- propName, pvalue, protectedProperties.contains(propName)) );
+ result.add( new NodeProperty( propName, pvalue,
+ AbstractResourceKind.isProtectedProperty(propName)) );
}
}
return result;
@@ -409,11 +137,11 @@
* Create a default value for the specified property name and resource
* kind
*/
- Object createDefaultValue( String propName, String resourceKind ) {
+ Object createDefaultValue( String propName, ResourceKind resourceKind ) {
String result = "";
- if( P_RESOURCETYPE.equals(propName) && K_VERSION_HISTORY.equals(resourceKind) ) {
+ if( P_RESOURCETYPE.equals(propName) && (resourceKind instanceof VersionHistory) ) {
StringBuffer rtvv = new StringBuffer();
try {
rtvv.append(
@@ -427,7 +155,7 @@
result = rtvv.toString();
}
else if( P_SUPPORTED_METHOD_SET.equals(propName) ) {
- Iterator i = (mhelp.getSupportedMethods(resourceKind)).iterator();
+ Iterator i = resourceKind.getSupportedMethods().iterator();
StringBuffer smsv = new StringBuffer();
while( i.hasNext() ) {
String m = (String) i.next();
@@ -442,7 +170,7 @@
result = smsv.toString();
}
else if( P_SUPPORTED_LIVE_PROPERTY_SET.equals(propName) ) {
- Iterator i = ((Set)supportedLiveProperties.get(resourceKind)).iterator();
+ Iterator i = resourceKind.getSupportedLiveProperties().iterator();
StringBuffer spsv = new StringBuffer();
while( i.hasNext() ) {
String p = (String) i.next();
@@ -458,7 +186,7 @@
result = spsv.toString();
}
else if( P_SUPPORTED_REPORT_SET.equals(propName) ) {
- Iterator i = rhelp.getSupportedReports().iterator();
+ Iterator i = resourceKind.getSupportedReports().iterator();
StringBuffer srsv = new StringBuffer();
while( i.hasNext() ) {
String r = (String) i.next();
@@ -600,42 +328,6 @@
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());
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>