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/08/07 15:11:53 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method PropPatchMethod.java
pnever 2002/08/07 06:11:53
Modified: src/webdav/server/org/apache/slide/webdav/method
PropPatchMethod.java
Log:
Fixed bug in checkPropertyModification(): computed properties cannot be set.
Revision Changes Path
1.56 +48 -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.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- PropPatchMethod.java 27 Jun 2002 10:49:59 -0000 1.55
+++ PropPatchMethod.java 7 Aug 2002 13:11:53 -0000 1.56
@@ -143,7 +143,7 @@
/**
* Constructor.
- *
+ *
* @param token the token for accessing the namespace
* @param config configuration of the WebDAV servlet
*/
@@ -179,9 +179,9 @@
propertiesToRemove = new PropPatchProperties();
if (requestBody.length() != 0) {
-
+
try {
-
+
Element setNode = null;
Element removeNode = null;
@@ -198,17 +198,17 @@
child = (Element)childrenIterator.next();
if (E_SET.equals(child.getName())) {
propertiesToSet.add(getPropElement(child));
- }
+ }
else if (E_REMOVE.equals(child.getName())) {
propertiesToRemove.add(getPropElement(child));
- }
+ }
else {
throw new JDOMException("Expected <"+E_SET+"> or <"+E_REMOVE+"> element");
- }
- }
+ }
+ }
- }
+ }
catch (PropertyParseException e) {
try {
resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
@@ -221,17 +221,17 @@
catch (JDOMException e) {
try {
resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
- }
+ }
catch (IOException ioe) {
ioe.printStackTrace();
- }
+ }
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- }
+ }
catch (IOException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
}
+ }
else {
try {
resp.sendError(WebdavStatus.SC_BAD_REQUEST, "Request content must not be empty");
@@ -290,8 +290,8 @@
NodeRevisionDescriptor revisionDescriptor = null;
if (revisionNumber != null) {
try {
- revisionDescriptor = content.retrieve
- (slideToken, revisionDescriptors);
+ revisionDescriptor = content.retrieve
+ (slideToken, revisionDescriptors);
} catch (RevisionDescriptorNotFoundException e) {
}
}
@@ -301,7 +301,7 @@
}
ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, resourcePath, revisionDescriptor);
-
+
// check preconditions
ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptors, revisionDescriptor, resourceKind);
if (violatedPrecondition != null) {
@@ -321,7 +321,7 @@
// Modifying the properties
Iterator propertyIterator = null;
-
+
propertyIterator = propertiesToSet.iterator();
PropPatchProperty currentProperty = null;
while (propertyIterator.hasNext()) {
@@ -372,7 +372,7 @@
sendPreconditionViolation(e);
throw e;
} catch (Exception e) {
-// e.printStackTrace();
+ // e.printStackTrace();
resp.setStatus(getErrorCode(e)); // special handling needed
throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
}
@@ -380,7 +380,7 @@
// No serious errors. Printing the XML report.
writeReport();
-
+
if (!allOperationsExcecuted) {
throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
}
@@ -426,16 +426,14 @@
property.setViolatedPrecondition(violatedPrecondition);
}
else {
-
- NodeProperty originalProperty = rd.getProperty(property.getName(), property.getNamespace());
- if (originalProperty == null) {
- // those virtual live properties can not be modified
- result = (!property.getName().equals(P_LOCKDISCOVERY)) &&
- (!property.getName().equals(P_SUPPORTEDLOCK));
- }
- else {
- result = !originalProperty.isProtected();
- }
+ NodeProperty originalProperty = rd.getProperty(property.getName(), property.getNamespace());
+ if (originalProperty == null) {
+ // computed properties can not be modified
+ result = (!AbstractResourceKind.isComputedProperty(property.getName()));
+ }
+ else {
+ result = !originalProperty.isProtected();
+ }
if (!result) property.setStatusCode(WebdavStatus.SC_CONFLICT);
}
return result;
@@ -484,7 +482,7 @@
* the <code><propstat></code> elements to.
*/
private void addPropstatElements(PropPatchProperties properties, Element response) {
-
+
Iterator propertyIterator = properties.iterator();
while(propertyIterator.hasNext()) {
PropPatchProperty property = (PropPatchProperty) propertyIterator.next();
@@ -566,9 +564,9 @@
}
if ( !E_CHECKOUT_CHECKIN.equals(autoVersion) &&
- !E_CHECKOUT_UNLOCKED_CHECKIN.equals(autoVersion) &&
- !E_CHECKOUT.equals(autoVersion) &&
- !E_LOCKED_CHECKOUT.equals(autoVersion) ) {
+ !E_CHECKOUT_UNLOCKED_CHECKIN.equals(autoVersion) &&
+ !E_CHECKOUT.equals(autoVersion) &&
+ !E_LOCKED_CHECKOUT.equals(autoVersion) ) {
return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_PROPERTY,
WebdavStatus.SC_FORBIDDEN);
}
@@ -604,20 +602,20 @@
* otherwise <code>null</code>).
*/
private ViolatedPrecondition getPropertySpecificPreconditionViolation(PropPatchProperty property) {
-
- // check precondition DAV:cannot-modify-protected-property
- if ( AbstractResourceKind.isProtectedProperty(property.getName()) &&
- DeltavConstants.DELTAV_PROPERTY_LIST.contains(property.getName()) ) {
- return new ViolatedPrecondition(C_CANNOT_MODIFY_PROTECTED_PROPERTY,
- WebdavStatus.SC_CONFLICT);
- }
-
- // check precondition DAV:supported-live-property
- // ...is there any property to check here yet ?
- return null;
+ // check precondition DAV:cannot-modify-protected-property
+ if ( AbstractResourceKind.isProtectedProperty(property.getName()) &&
+ DeltavConstants.DELTAV_PROPERTY_LIST.contains(property.getName()) ) {
+ return new ViolatedPrecondition(C_CANNOT_MODIFY_PROTECTED_PROPERTY,
+ WebdavStatus.SC_CONFLICT);
}
+ // check precondition DAV:supported-live-property
+ // ...is there any property to check here yet ?
+
+ return null;
+ }
+
/**
* Generate <responsedescription> for the given precondition violation.
*
@@ -666,14 +664,14 @@
* implementations of RequestedProperty.
*
* @param name the name of the propery.
- * @param namespacePrefix the namespace prefix of the propery.
- * @param namespaceUri the namespace URI of the propery.
+ * @param namespacePrefix the namespace prefix of the propery.
+ * @param namespaceUri the namespace URI of the propery.
* @param text the text of the propery element.
* @param children the children of the propery element.
*
* @return the created RequestedProperty.
*/
- protected RequestedProperty createRequestedProperty(String name, String namespacePrefix, String namespaceUri, String text, List children) {
+ protected RequestedProperty createRequestedProperty(String name, String namespacePrefix, String namespaceUri, String text, List children) {
String value = text;
if (children.size() > 0) {
@@ -740,7 +738,7 @@
super(propertyName, namespace);
this.value = value;
}
-
+
/**
* Returns the value of the property.
*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>