pnever 02/05/23 06:14:59
Modified: src/webdav/server/org/apache/slide/webdav/util
VersioningHelper.java
Log:
Added CHECKIN precondition C_NO_OVERWRITE_BY_AUTO_UPDATE
Revision Changes Path
1.52 +41 -19
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.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- VersioningHelper.java 22 May 2002 16:25:06 -0000 1.51
+++ VersioningHelper.java 23 May 2002 13:14:59 -0000 1.52
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.51 2002/05/22 16:25:06 pnever Exp $
- * $Revision: 1.51 $
- * $Date: 2002/05/22 16:25:06 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.52 2002/05/23 13:14:59 pnever Exp $
+ * $Revision: 1.52 $
+ * $Date: 2002/05/23 13:14:59 $
*
* ====================================================================
*
@@ -949,6 +949,17 @@
NodeProperty coutProp = rNrd.getProperty( P_CHECKED_OUT );
NodeProperty predSetProp = rNrd.getProperty( P_PREDECESSOR_SET );
+ NodeProperty autoUpdProp = rNrd.getProperty( P_AUTO_UPDATE );
+
+ // prepare auto-update
+ NodeRevisionDescriptors autoUpdNrds = null;
+ NodeRevisionDescriptor autoUpdNrd = null;
+ if( autoUpdProp != null ) {
+ Element autoUpdElm = pHelp.parsePropertyValue(
(String)autoUpdProp.getValue() );
+ String autoUpdUri = autoUpdElm.getTextTrim();
+ autoUpdNrds = content.retrieve( sToken, autoUpdUri );
+ autoUpdNrd = content.retrieve( sToken, autoUpdNrds );
+ }
// Retrieve VHR
Element coutElm = pHelp.parsePropertyValue( (String)coutProp.getValue()
);
@@ -964,7 +975,7 @@
NodeRevisionDescriptor vrNrdOld =
content.retrieve( sToken, vhrNrds, vrNrnOld ); // vrUriOld
- ViolatedPrecondition violatedPrecondition =
getCheckinPreconditionViolation(predSetProp, vhrNrds, forkOk, isWorkingResource);
+ ViolatedPrecondition violatedPrecondition =
getCheckinPreconditionViolation( predSetProp, vhrNrds, forkOk, autoUpdNrd );
if (violatedPrecondition != null) {
throw new PreconditionViolationException(violatedPrecondition,
rUri);
}
@@ -1042,11 +1053,8 @@
content.store( sToken, vhrUri, vrNrdNew, null ); //revisionContent=null
// auto-update
- NodeProperty auProp = rNrd.getProperty( P_AUTO_UPDATE );
- if( auProp != null ) {
- Element auElm = pHelp.parsePropertyValue( (String)auProp.getValue()
);
- String auUri = auElm.getTextTrim();
- update( auUri, vrUriNew );
+ if( autoUpdNrd != null ) {
+ update( autoUpdNrds, autoUpdNrd, vhrNrds, vrNrdNew );
}
// Set status created
@@ -1076,25 +1084,22 @@
* @param vhrNrds the NodeRevisionDescriptors of the associated VHR.
* @param isForkOk indicates if <code><fork-ok></code> is set in
* the request content.
- * @param isWorkingResource indicates that a working resource is being
checked-in
+ * @param autoUpdNrd the NodeRevisionDescriptor of the VCR
referenced via auto-update
+ * if not null, indicates that a working
resource is being checked-in
+ * for which the auto-update property was set
*
* @return the ViolatedPrecondition (if any).
*/
- protected ViolatedPrecondition getCheckinPreconditionViolation(NodeProperty
predSetProp, NodeRevisionDescriptors vhrNrds, boolean isForkOk, boolean
isWorkingResource) throws LinkedObjectNotFoundException, ServiceAccessException,
ObjectLockedException, RevisionDescriptorNotFoundException, JDOMException,
IllegalArgumentException, ObjectNotFoundException, AccessDeniedException {
-
- // *********************************
- // TODO:
- // DAV:no-overwrite-by-auto-update
- // *********************************
+ protected ViolatedPrecondition getCheckinPreconditionViolation(NodeProperty
predSetProp, NodeRevisionDescriptors vhrNrds, boolean isForkOk, NodeRevisionDescriptor
autoUpdNrd ) throws LinkedObjectNotFoundException, ServiceAccessException,
ObjectLockedException, RevisionDescriptorNotFoundException, JDOMException,
IllegalArgumentException, ObjectNotFoundException, AccessDeniedException, IOException {
ViolatedPrecondition violatedPrecondition = null;
if ( (predSetProp != null) && (predSetProp.getValue() != null) ) {
- XMLValue predecessors = new XMLValue(predSetProp.getValue().toString());
+ XMLValue predecessors = new XMLValue( (String)predSetProp.getValue() );
Iterator iterator = predecessors.iterator();
while (iterator.hasNext()) {
- String href = ((Element)iterator.next()).getText();
+ String href = ((Element)iterator.next()).getTextTrim();
if (href != null) {
UriHandler predecessorUriHandler = UriHandler.getUriHandler(
href);
@@ -1105,6 +1110,7 @@
return new ViolatedPrecondition(C_VERSION_HISTORY_IS_TREE,
WebdavStatus.SC_FORBIDDEN);
}
+ // check precondition C_CHECKIN_FORK_FORBIDDEN
NodeRevisionNumber predecessorNrn = new
NodeRevisionNumber(predecessorUriHandler.getVersionName());
NodeRevisionDescriptor predecessorNrd = content.retrieve(sToken,
vhrNrds,
@@ -1118,7 +1124,7 @@
(predecessorCheckinForkProperty.getValue() != null)
) {
String checkinFork =
getElementName(predecessorCheckinForkProperty.getValue().toString());
- // check precondition C_CHECKIN_FORK_FORBIDDEN
+
if (E_FORBIDDEN.equals(checkinFork)) {
return new
ViolatedPrecondition(C_CHECKIN_FORK_FORBIDDEN, WebdavStatus.SC_FORBIDDEN);
}
@@ -1127,6 +1133,22 @@
else if (E_DISCOURAGED.equals(checkinFork) && !isForkOk
) {
return new
ViolatedPrecondition(C_CHECKIN_FORK_DISCOURAGED, WebdavStatus.SC_CONFLICT);
}
+ }
+ }
+
+ // check precondition C_NO_OVERWRITE_BY_AUTO_UPDATE
+ NodeProperty cinProp = autoUpdNrd.getProperty( P_CHECKED_IN );
+ if( cinProp != null ) {
+ Element cinHrefElm = pHelp.parsePropertyValue(
(String)cinProp.getValue() );
+ UriHandler cinUh = new UriHandler( cinHrefElm.getTextTrim()
);
+ NodeRevisionNumber cinNrn = new NodeRevisionNumber(
cinUh.getVersionName() );
+ if(
vhrNrds.getUri().equals(cinUh.getAssociatedHistoryUri()) ) {
+ // violation
+ return new
ViolatedPrecondition(C_NO_OVERWRITE_BY_AUTO_UPDATE, WebdavStatus.SC_CONFLICT);
+ }
+ if( !vhrNrds.isAncestorDescendant(cinNrn, predecessorNrn) )
{
+ // violation
+ return new
ViolatedPrecondition(C_NO_OVERWRITE_BY_AUTO_UPDATE, WebdavStatus.SC_CONFLICT);
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>