juergen 2002/08/09 02:14:54
Modified: src/webdav/server/org/apache/slide/webdav/util/resourcekind
AbstractResourceKind.java ResourceKind.java
Log:
Added method isSupportedPropertyValue().
(ralf)
Revision Changes Path
1.13 +105 -3
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/resourcekind/AbstractResourceKind.java
Index: AbstractResourceKind.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/resourcekind/AbstractResourceKind.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- AbstractResourceKind.java 20 May 2002 12:10:15 -0000 1.12
+++ AbstractResourceKind.java 9 Aug 2002 09:14:54 -0000 1.13
@@ -78,6 +78,10 @@
import org.apache.slide.webdav.util.AclConstants;
import org.apache.slide.webdav.util.DaslConstants;
import org.apache.slide.webdav.util.UriHandler;
+import org.apache.slide.webdav.util.XMLValue;
+
+import org.jdom.JDOMException;
+import org.jdom.Element;
/**
* Abstraction of a WebDAV-compliant resource kind.
@@ -97,6 +101,56 @@
// computed properties
protected static Set computedProperties = new HashSet();
+ /**
+ * A String array containing the names of the Elements supported as a
+ * value of the <code><auto-version></code> property,
+ * e.g. <code>checkout-checkin</code>.
+ */
+ protected final static String[] SUPPORTED_AUTO_VERSION_ELEMENTS =
+ new String[] {E_CHECKOUT, E_CHECKOUT_CHECKIN, E_CHECKOUT_UNLOCKED_CHECKIN,
E_LOCKED_CHECKOUT};
+
+ /**
+ * A String array containing the names of the Elements supported as a
+ * value of the <code><checkout-fork></code> property,
+ * e.g. <code>discouraged</code>.
+ */
+ protected final static String[] SUPPORTED_CHECKOUT_FORK_ELEMENTS =
+ new String[] {E_DISCOURAGED, E_FORBIDDEN};
+
+ /**
+ * A String array containing the names of the Elements supported as a
+ * value of the <code><checkin-fork></code> property,
+ * e.g. <code>discouraged</code>.
+ */
+ protected final static String[] SUPPORTED_CHECKIN_FORK_ELEMENTS =
+ new String[] {E_DISCOURAGED, E_FORBIDDEN};
+
+ /**
+ * The values of {@link #SUPPORTED_AUTO_VERSION_ELEMENTS
SUPPORTED_AUTO_VERSION_ELEMENTS}
+ * as a (unmodifiable) List.
+ */
+ protected final static List SUPPORTED_AUTO_VERSION_ELEMENTS_LIST =
Collections.unmodifiableList(Arrays.asList(SUPPORTED_AUTO_VERSION_ELEMENTS));
+
+ /**
+ * The values of {@link #SUPPORTED_CHECKOUT_FORK_ELEMENTS
SUPPORTED_CHECKOUT_FORK_ELEMENTS}
+ * as a (unmodifiable) List.
+ */
+ protected final static List SUPPORTED_CHECKOUT_FORK_ELEMENTS_LIST =
Collections.unmodifiableList(Arrays.asList(SUPPORTED_CHECKOUT_FORK_ELEMENTS));
+
+ /**
+ * The values of {@link #SUPPORTED_CHECKIN_FORK_ELEMENTS
SUPPORTED_CHECKIN_FORK_ELEMENTS}
+ * as a (unmodifiable) List.
+ */
+ protected final static List SUPPORTED_CHECKIN_FORK_ELEMENTS_LIST =
Collections.unmodifiableList(Arrays.asList(SUPPORTED_CHECKIN_FORK_ELEMENTS));
+
+ /**
+ * Maps the names of the properties that have a restricted set of supported
+ * Element values to the List of names of these supported Elements
+ * (e.g. {@link #SUPPORTED_AUTO_VERSION_ELEMENTS_LIST
SUPPORTED_AUTO_VERSION_ELEMENTS_LIST}.
+ */
+ protected final static Map RESTRICTED_PROPERTY_VALUE_MAP = new HashMap();
+
+
// static initialization
static {
// features
@@ -164,6 +218,11 @@
liveProperties.addAll( WebdavConstants.WEBDAV_PROPERTY_LIST );
liveProperties.addAll( AclConstants.ACL_PROPERTY_LIST );
liveProperties.addAll( DeltavConstants.DELTAV_PROPERTY_LIST );
+
+ // restricted property values
+ RESTRICTED_PROPERTY_VALUE_MAP.put(P_AUTO_VERSION,
SUPPORTED_AUTO_VERSION_ELEMENTS_LIST);
+ RESTRICTED_PROPERTY_VALUE_MAP.put(P_CHECKOUT_FORK,
SUPPORTED_CHECKOUT_FORK_ELEMENTS_LIST);
+ RESTRICTED_PROPERTY_VALUE_MAP.put(P_CHECKIN_FORK,
SUPPORTED_CHECKIN_FORK_ELEMENTS_LIST);
}
/**
@@ -380,6 +439,49 @@
result.addAll( superkind.getSupportedReports() );
}
return result;
+ }
+
+ /**
+ * Some properties (e.g. <code><auto-version></code>) have a
+ * restricted set of supported values.
+ * If the value set of the given <code>property</code> is restricted and
+ * the given <code>value</code> is not contained in that set, this method
+ * returns <code>false</code>, otherwise <code>true</code>.
+ *
+ * @param propertyName the name of the property.
+ * @param value the value to check.
+ *
+ * @return <code>false</code> if the value is not allowed, otherwise
+ * <code>true</code>.
+ */
+ public boolean isSupportedPropertyValue(String propertyName, Object value) {
+
+ boolean isSupported = true;
+ List listOfRestrictedValues =
(List)RESTRICTED_PROPERTY_VALUE_MAP.get(propertyName);
+ if (listOfRestrictedValues != null) {
+
+ if (value == null) {
+ return false;
+ }
+
+ XMLValue xmlValue = null;
+ if (value instanceof XMLValue) {
+ xmlValue = (XMLValue)value;
+ }
+ else {
+ try {
+ xmlValue = new XMLValue(value.toString());
+ }
+ catch (JDOMException e) {
+ return false;
+ }
+ }
+ isSupported =
+ (xmlValue.size() > 0) &&
+
listOfRestrictedValues.contains(((Element)xmlValue.iterator().next()).getName());
+ }
+
+ return isSupported;
}
/**
1.5 +19 -3
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/resourcekind/ResourceKind.java
Index: ResourceKind.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/resourcekind/ResourceKind.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ResourceKind.java 25 Apr 2002 21:27:32 -0000 1.4
+++ ResourceKind.java 9 Aug 2002 09:14:54 -0000 1.5
@@ -126,5 +126,21 @@
* Get the set reports supported by this resource kind.
*/
Set getSupportedReports();
+
+ /**
+ * Some properties (e.g. <code><auto-version></code>) have a
+ * restricted set of supported values.
+ * If the value set of the given <code>property</code> is restricted and
+ * the given <code>value</code> is not contained in that set, this method
+ * returns <code>false</code>, otherwise <code>true</code>.
+ *
+ * @param propertyName the name of the property.
+ * @param value the value to check.
+ *
+ * @return <code>false</code> if the value is not allowed, otherwise
+ * <code>true</code>.
+ */
+ boolean isSupportedPropertyValue(String propertyName, Object value);
+
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>