juergen 2002/10/30 02:02:45
Modified: src/webdav/server/org/apache/slide/webdav/method
PropPatchMethod.java
Log:
Check values for property <getcontentlanguage/>.
(ralf)
Revision Changes Path
1.62 +44 -6
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java
Index: PropPatchMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- PropPatchMethod.java 12 Aug 2002 12:55:02 -0000 1.61
+++ PropPatchMethod.java 30 Oct 2002 10:02:45 -0000 1.62
@@ -426,16 +426,54 @@
property.setErrorMessage("Property " +
property.getQualifiedNameAsElementString() + " is protected");
}
- if ( result && (property.getValue() != null) ) {
- if ( ! resourceKind.isSupportedPropertyValue(property.getName(),
property.getValue()) ) {
+ if ( result && !isSupportedPropertyValue(property, resourceKind) ) {
property.setErrorMessage("Value " + property.getValue() + " is
not supported by property " + property.getQualifiedNameAsElementString());
result = false;
}
- }
if (!result) property.setStatusCode(WebdavStatus.SC_CONFLICT);
}
return result;
+ }
+
+ /**
+ * Return <code>true</code> if the given <code>property</code> value is
supported
+ * for that property of the <code>resourceKind</code>
+ *
+ * @param property the property to check.
+ * @param resourceKind the ResourceKind.
+ *
+ * @return <code>true</code> if the value is supported.
+ */
+ private boolean isSupportedPropertyValue(PropPatchProperty property,
ResourceKind resourceKind) {
+
+ boolean isSupportedValue = true;
+ if (property.getValue() != null) {
+
+ if ( ! resourceKind.isSupportedPropertyValue(property.getName(),
property.getValue()) ) {
+ isSupportedValue = false;
+ }
+
+ if (P_GETCONTENTLANGUAGE.equals(property.getName())) {
+
+ StringTokenizer tokenizer = new
StringTokenizer(property.getValue(), "-");
+ String token = null;
+ while ( isSupportedValue && tokenizer.hasMoreTokens() ) {
+ token = tokenizer.nextToken();
+ isSupportedValue = ( (token.length() >= 1) && (token.length()
<= 8) );
+ int i = 0;
+ while (isSupportedValue && (i < token.length()) ) {
+ char character = token.charAt(i);
+ isSupportedValue =
+ ((character >= 'a') && (character <= 'z')) ||
+ ((character >= 'A') && (character <= 'Z'));
+ ++i;
+ }
+ }
+ }
+
+ }
+ return isSupportedValue;
}
--
To unsubscribe, e-mail: <mailto:slide-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:slide-dev-help@;jakarta.apache.org>