juergen 02/03/15 04:44:54
Modified: src/webdav/server/org/apache/slide/webdav/util
VersioningHelper.java
Log:
Methods checkin() and checkout() now throw PreconditionViolationException instead
of sending an error response.
(ralf)
Revision Changes Path
1.10 +11 -34
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
Index: VersioningHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- VersioningHelper.java 15 Mar 2002 10:07:38 -0000 1.9
+++ VersioningHelper.java 15 Mar 2002 12:44:54 -0000 1.10
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.9 2002/03/15 10:07:38 juergen Exp $
- * $Revision: 1.9 $
- * $Date: 2002/03/15 10:07:38 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.10 2002/03/15 12:44:54 juergen Exp $
+ * $Revision: 1.10 $
+ * $Date: 2002/03/15 12:44:54 $
*
* ====================================================================
*
@@ -310,7 +310,7 @@
* Checkout the specified resource
*/
public void checkout( String resourcePath, boolean forkOk, boolean
applyToVersion )
- throws SlideException, JDOMException, IOException {
+ throws SlideException, JDOMException, IOException,
PreconditionViolationException {
NodeRevisionDescriptors rNrds = retrieveRevisionDescriptors( resourcePath );
NodeRevisionDescriptor rNrd = retrieveLatestRevisionDescriptor(
resourcePath, rNrds );
@@ -322,7 +322,7 @@
*/
public void checkout( NodeRevisionDescriptors rNrds,
NodeRevisionDescriptor rNrd, boolean forkOk, boolean applyToVersion )
- throws SlideException, JDOMException, IOException {
+ throws SlideException, JDOMException, IOException,
PreconditionViolationException {
Iterator i;
ResourceKind rRk = AbstractResourceKind.determineResourceKind( rNrd );
@@ -330,8 +330,7 @@
if( !rRk.isSupportedMethod(req.getMethod()) ) {
// check precondition C_MUST_BE_CHECKED_IN
if( rRk instanceof CheckedOut ) {
- sendPreconditionViolation(new
ViolatedPrecondition(C_MUST_BE_CHECKED_IN, WebdavStatus.SC_CONFLICT));
- return;
+ throw new PreconditionViolationException(new
ViolatedPrecondition(C_MUST_BE_CHECKED_IN, WebdavStatus.SC_CONFLICT));
}
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
return;
@@ -350,8 +349,7 @@
ViolatedPrecondition violatedPrecondition =
getCheckoutPreconditionViolation(cinNrd, cinNrds, forkOk);
if (violatedPrecondition != null) {
- sendPreconditionViolation(violatedPrecondition);
- return;
+ throw new PreconditionViolationException(violatedPrecondition);
}
addUriToCheckoutSet(cinNrd, rNrds.getUri());
@@ -440,7 +438,7 @@
* Checkin the specified resource
*/
public void checkin( String resourcePath, boolean forkOk, boolean
keepCheckedOut )
- throws SlideException, JDOMException, IOException {
+ throws SlideException, JDOMException, IOException,
PreconditionViolationException {
NodeRevisionDescriptors rNrds = retrieveRevisionDescriptors( resourcePath );
NodeRevisionDescriptor rNrd = retrieveLatestRevisionDescriptor(
resourcePath, rNrds );
@@ -452,7 +450,7 @@
*/
public void checkin( NodeRevisionDescriptors rNrds,
NodeRevisionDescriptor rNrd, boolean forkOk, boolean keepCheckedOut )
- throws SlideException, JDOMException, IOException {
+ throws SlideException, JDOMException, IOException,
PreconditionViolationException {
Iterator i;
Enumeration j;
@@ -462,8 +460,7 @@
if( !rRk.isSupportedMethod(req.getMethod()) ) {
// check precondition C_MUST_BE_CHECKED_OUT
if( !(rRk instanceof CheckedOut) ) {
- sendPreconditionViolation(new
ViolatedPrecondition(C_MUST_BE_CHECKED_OUT, WebdavStatus.SC_CONFLICT));
- return;
+ throw new PreconditionViolationException(new
ViolatedPrecondition(C_MUST_BE_CHECKED_OUT, WebdavStatus.SC_CONFLICT));
}
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
return;
@@ -488,8 +485,7 @@
ViolatedPrecondition violatedPrecondition =
getCheckinPreconditionViolation(predSetProp, vhrNrds, forkOk);
if (violatedPrecondition != null) {
- sendPreconditionViolation(violatedPrecondition);
- return;
+ throw new PreconditionViolationException(violatedPrecondition);
}
removeUriFromCheckoutSet(vrNrdOld, rNrds.getUri());
@@ -678,25 +674,6 @@
}
}
}
-
- /**
- * Sends a precondition vilolation response.
- *
- * @param violatedPrecondition the precondition that has been violated.
- */
- protected void sendPreconditionViolation(ViolatedPrecondition
violatedPrecondition) throws IOException {
-
- if (violatedPrecondition != null) {
-
- resp.setStatus(violatedPrecondition.getStatusCode());
-
- Element errorElement = new Element(E_ERROR,
Namespace.getNamespace(DEFAULT_NAMESPACE));
- Element preconditionElement = new
Element(violatedPrecondition.getPrecondition(),
Namespace.getNamespace(DEFAULT_NAMESPACE));
- errorElement.addContent(preconditionElement);
- new XMLOutputter().output(errorElement, resp.getWriter());
- }
- }
-
/**
** Expects a String containing an XML Element like
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>