luetzkendorf 2005/01/10 10:15:08
Modified: src/webdav/server/org/apache/slide/webdav/method
PropPatchMethod.java
Log:
Reworked and unified evaluation of precondition violations.
Uses new resourcekind features.
Revision Changes Path
1.90 +20 -50
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.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- PropPatchMethod.java 3 Jan 2005 15:07:07 -0000 1.89
+++ PropPatchMethod.java 10 Jan 2005 18:15:08 -0000 1.90
@@ -30,7 +30,6 @@
import java.util.List;
import org.apache.slide.common.NamespaceAccessToken;
-import org.apache.slide.common.PropertyName;
import org.apache.slide.common.PropertyParseException;
import org.apache.slide.common.RequestedPropertiesImpl;
import org.apache.slide.common.RequestedProperty;
@@ -60,6 +59,7 @@
import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
import org.apache.slide.webdav.util.resourcekind.CheckedInVersionControlled;
import org.apache.slide.webdav.util.resourcekind.ResourceKind;
+import org.apache.slide.webdav.util.resourcekind.ResourceKindManager;
import org.jdom.CDATA;
import org.jdom.Comment;
import org.jdom.Document;
@@ -309,8 +309,8 @@
if( propertyValue.toString().indexOf('<') >= 0 ) {
try {
XMLValue xmlValue = new
XMLValue(propertyValue.toString(),
Namespace.getNamespace(currentProperty.getNamespace()));
- if
(AbstractResourceKind.isLiveProperty(currentProperty.getName())) {
- convertHrefValueToRelativeURL (xmlValue,
getSlideContextPath(), config);
+ if
(resourceKind.isSupportedLiveProperty(currentProperty.getPropertyName())) {
+ convertHrefValueToRelativeURL(xmlValue,
getSlideContextPath(), config);
}
Iterator iterator = xmlValue.iterator();
while (iterator.hasNext()) {
@@ -335,10 +335,8 @@
}
}
}
- NodeProperty newProperty =
- new NodeProperty(currentProperty.getName(),
- finalValue,
- currentProperty.getNamespace());
+ NodeProperty newProperty = new NodeProperty(
+ currentProperty.getPropertyName(), finalValue);
revisionDescriptor.setProperty(newProperty);
}
@@ -352,8 +350,7 @@
currentProperty = (PropPatchProperty)propertyIterator.next();
if (checkPropertyModification(currentProperty,
revisionDescriptor, resourceKind)) {
-
revisionDescriptor.removeProperty(currentProperty.getName(),
-
currentProperty.getNamespace());
+
revisionDescriptor.removeProperty(currentProperty.getPropertyName());
}
else {
allOperationsExcecuted = false;
@@ -440,28 +437,21 @@
private boolean checkPropertyModification(PropPatchProperty property,
NodeRevisionDescriptor rd, ResourceKind resourceKind) {
- ViolatedPrecondition violatedPrecondition =
getPropertySpecificPreconditionViolation(property);
+ ViolatedPrecondition violatedPrecondition =
+ getPropertySpecificPreconditionViolation(resourceKind, property);
if (violatedPrecondition != null) {
property.setViolatedPrecondition(violatedPrecondition);
return false;
- }
- else {
- boolean modificationAllowed = false;
-
- modificationAllowed = !resourceKind.isProtectedProperty(
- PropertyName.getPropertyName(property.getName(),
property.getNamespace()));
-
- if (!modificationAllowed) {
- property.setErrorMessage("Property " +
- property.getQualifiedNameAsElementString() + " is
protected");
- } else if (!isSupportedPropertyValue(property, resourceKind)) {
- property.setErrorMessage("Value " + property.getValue() + "
is not supported by property " + property.getQualifiedNameAsElementString());
- modificationAllowed = false;
+ } else {
+ if (!isSupportedPropertyValue(property, resourceKind)) {
+ property.setErrorMessage("Value " + property.getValue() +
+ " is not supported by property " +
property.getQualifiedNameAsElementString());
+
+ property.setStatusCode(WebdavStatus.SC_CONFLICT);
+ return false;
}
- if (!modificationAllowed)
property.setStatusCode(WebdavStatus.SC_CONFLICT);
-
- return modificationAllowed;
+ return true;
}
}
@@ -477,28 +467,8 @@
private boolean isSupportedPropertyValue(PropPatchProperty property,
ResourceKind resourceKind) {
if (property.getValue() != null) {
-
return resourceKind.isSupportedPropertyValue(
- property.getName(), property.getValue());
-
-// 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;
-// }
-// }
-// }
-
+ property.getPropertyName(), property.getValue());
}
return true;
}
@@ -666,11 +636,11 @@
* @return the precondition that has been violated (if any,
* otherwise <code>null</code>).
*/
- private ViolatedPrecondition
getPropertySpecificPreconditionViolation(PropPatchProperty property) {
+ private ViolatedPrecondition getPropertySpecificPreconditionViolation(
+ ResourceKind resourceKind, PropPatchProperty property) {
// check precondition DAV:cannot-modify-protected-property
- if ( AbstractResourceKind.isProtectedProperty(property.getName()) &&
-
DeltavConstants.DELTAV_PROPERTY_LIST.contains(property.getName()) ) {
+ if
(ResourceKindManager.isProtectedProperty(property.getPropertyName())) {
return new
ViolatedPrecondition(C_CANNOT_MODIFY_PROTECTED_PROPERTY,
WebdavStatus.SC_CONFLICT);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]