pnever 02/05/03 09:35:08
Modified: src/webdav/server/org/apache/slide/webdav/util
VersioningHelper.java
Log:
- update() now working (still open: "non-formal" preconditions)
- checkin for WR (still open: additional precondition and auto-update processing)
- fixed problems which hindered deltav to work properly with Slide's
MemoryDescriptors and FileContent stores
Revision Changes Path
1.45 +83 -45
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.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- VersioningHelper.java 2 May 2002 19:49:37 -0000 1.44
+++ VersioningHelper.java 3 May 2002 16:35:08 -0000 1.45
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.44 2002/05/02 19:49:37 pnever Exp $
- * $Revision: 1.44 $
- * $Date: 2002/05/02 19:49:37 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.45 2002/05/03 16:35:08 pnever Exp $
+ * $Revision: 1.45 $
+ * $Date: 2002/05/03 16:35:08 $
*
* ====================================================================
*
@@ -98,9 +98,13 @@
import org.apache.slide.lock.NodeLock;
import org.apache.slide.lock.Lock;
+import org.apache.slide.macro.Macro;
+import org.apache.slide.macro.DeleteMacroException;
+
import org.apache.slide.security.AccessDeniedException;
import org.apache.slide.structure.Structure;
+import org.apache.slide.structure.ObjectNode;
import org.apache.slide.structure.SubjectNode;
import org.apache.slide.structure.ActionNode;
import org.apache.slide.structure.ObjectNotFoundException;
@@ -158,6 +162,7 @@
private Content content = null;
private Structure structure = null;
+ private Macro macro = null;
private Lock lock = null;
private HttpServletRequest req = null;
private HttpServletResponse resp = null;
@@ -186,6 +191,7 @@
this.sConf = sConf;
this.content = nsaToken.getContentHelper();
this.structure = nsaToken.getStructureHelper();
+ this.macro = nsaToken.getMacroHelper();
this.lock = nsaToken.getLockHelper();
this.pHelp = PropertyHelper.getPropertyHelper( sToken,nsaToken );
ActionNode actionNode =
nsaToken.getNamespaceConfig().getModifyRevisionMetadataAction();
@@ -363,14 +369,16 @@
rNrd.setProperty(
new NodeProperty(P_CHECKED_IN, pHelp.createHrefValue(vrUri)) );
vhrNrd.setETag( vhrUri.hashCode()+"_" ); // P_GETETAG
+ vhrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
vhrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
vhrNrd.setContentLength( 0 ); // P_GETCONTENTLENGTH
vhrNrd.setName( vhrUh.getHistoryName() ); // P_DISPLAYNAME
vhrNrd.setProperty(
new NodeProperty(P_VERSION_SET, pHelp.createHrefValue(vrUri)) );
- vrNrd.setName(vrUh.getVersionName() ); // P_DISPLAYNAME
vrNrd.setETag( vrUri.hashCode()+"_"+req.getContentLength() ); // P_GETETAG
vrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
+ vrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
+ vrNrd.setName(vrUh.getVersionName() ); // P_DISPLAYNAME
vrNrd.setProperty(
new NodeProperty(P_VERSION_NAME, vrUh.getVersionName()) );
@@ -564,7 +572,7 @@
public String checkout( String resourcePath, boolean forkOk, boolean
applyToVersion, boolean isAutoVersionCheckout )
throws SlideException, JDOMException, IOException,
PreconditionViolationException {
- UriHandler rUh = new UriHandler( nsaToken.getName(), resourcePath );
+ UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
NodeRevisionDescriptors rNrds = retrieveRevisionDescriptors( resourcePath );
NodeRevisionDescriptor rNrd = retrieveLatestRevisionDescriptor(
resourcePath, rNrds );
@@ -590,7 +598,7 @@
* @throws PreconditionViolatedException
*/
public String checkout( NodeRevisionDescriptors rNrds,
- NodeRevisionDescriptor rNrd, boolean forkOk, boolean
applyToVersion )
+ NodeRevisionDescriptor rNrd, boolean forkOk, boolean
applyToVersion )
throws SlideException, JDOMException, IOException,
PreconditionViolationException {
return checkout(rNrds, rNrd, forkOk, applyToVersion, false);
}
@@ -610,7 +618,7 @@
* @throws PreconditionViolatedException
*/
public String checkout( NodeRevisionDescriptors rNrds,
- NodeRevisionDescriptor rNrd, boolean forkOk, boolean
applyToVersion, boolean isAutoVersionCheckout )
+ NodeRevisionDescriptor rNrd, boolean forkOk, boolean
applyToVersion, boolean isAutoVersionCheckout )
throws SlideException, JDOMException, IOException,
PreconditionViolationException {
Iterator i;
@@ -700,7 +708,7 @@
* @throws PreconditionViolatedException
*/
public String checkout( NodeRevisionDescriptors rNrds, NodeRevisionDescriptor
rNrd, NodeRevisionContent rNrc,
- boolean forkOk, String autoUpdateUri )
+ boolean forkOk, String autoUpdateUri )
throws SlideException, JDOMException, IOException,
PreconditionViolationException {
Iterator i;
@@ -719,7 +727,7 @@
if( rRk instanceof Version ) {
- UriHandler rUh = new UriHandler( nsaToken.getName(), rUri );
+ UriHandler rUh = UriHandler.getUriHandler( nsaToken, rUri );
String vhUri = rUh.getAssociatedHistoryUri();
ViolatedPrecondition violatedPrecondition =
getCheckoutPreconditionViolation(rNrds, rNrd, forkOk);
@@ -778,7 +786,7 @@
}
content.create( sToken, wrUri, wrNrd, rNrc );
-
+
// Set status created
resp.setStatus( WebdavStatus.SC_CREATED );
return wrUri;
@@ -940,9 +948,14 @@
* @throws PreconditionViolatedException
*/
public String checkin( NodeRevisionDescriptors rNrds,
- NodeRevisionDescriptor rNrd, boolean forkOk, boolean
keepCheckedOut )
+ NodeRevisionDescriptor rNrd, boolean forkOk, boolean
keepCheckedOut )
throws SlideException, JDOMException, IOException,
PreconditionViolationException {
+ // *************************************
+ // TODO:
+ // process auto-update property for WRs
+ // *************************************
+
Iterator i;
Enumeration j;
NodeRevisionContent rNrc = content.retrieve( sToken, rNrds, rNrd );
@@ -952,22 +965,24 @@
if( !rRk.isSupportedMethod(req.getMethod()) ) {
// check precondition C_MUST_BE_CHECKED_OUT
if( !(rRk instanceof CheckedOut) ) {
- throw new PreconditionViolationException(new
ViolatedPrecondition(C_MUST_BE_CHECKED_OUT,
-
WebdavStatus.SC_CONFLICT),
- rNrds.getUri());
+ throw new PreconditionViolationException(
+ new ViolatedPrecondition(C_MUST_BE_CHECKED_OUT,
WebdavStatus.SC_CONFLICT), rUri);
}
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
- if( rRk instanceof CheckedOutVersionControlled ) {
+ if( rRk instanceof CheckedOutVersionControlled || rRk instanceof Working ) {
+
+ boolean isWorkingResource = (rRk instanceof Working);
+
NodeProperty coutProp = rNrd.getProperty( P_CHECKED_OUT );
NodeProperty predSetProp = rNrd.getProperty( P_PREDECESSOR_SET );
// Retrieve VHR
Element coutElm = pHelp.parsePropertyValue( (String)coutProp.getValue()
);
String vrUriOld = coutElm.getTextTrim();
- UriHandler vrUhOld = new UriHandler( nsaToken.getName(), vrUriOld );
+ UriHandler vrUhOld = UriHandler.getUriHandler( nsaToken, vrUriOld );
String vhrUri = vrUhOld.getAssociatedHistoryUri();
NodeRevisionDescriptors vhrNrds = retrieveRevisionDescriptors( vhrUri );
NodeRevisionDescriptor vhrNrd = retrieveLatestRevisionDescriptor(
vhrUri, vhrNrds );
@@ -977,14 +992,14 @@
NodeRevisionDescriptor vrNrdOld =
retrieveLatestRevisionDescriptor( vrUriOld, vhrNrds );
- ViolatedPrecondition violatedPrecondition =
getCheckinPreconditionViolation(predSetProp, vhrNrds, forkOk);
+ ViolatedPrecondition violatedPrecondition =
getCheckinPreconditionViolation(predSetProp, vhrNrds, forkOk, isWorkingResource);
if (violatedPrecondition != null) {
- throw new PreconditionViolationException(violatedPrecondition,
rNrds.getUri());
+ throw new PreconditionViolationException(violatedPrecondition,
rUri);
}
// Create new VR in the MAIN branch
NodeRevisionDescriptor vrNrdNew =
- new NodeRevisionDescriptor(req.getContentLength());
+ new NodeRevisionDescriptor( rNrd.getContentLength() );
i = pHelp.createInitialProperties(VersionImpl.getInstance()).iterator();
while( i.hasNext() )
vrNrdNew.setProperty( (NodeProperty)i.next() );
@@ -998,42 +1013,59 @@
if( !vrNrdNew.exists(p.getName()) )
vrNrdNew.setProperty( p );
}
- // Copy content-type VCR->VR
+ // Copy content-type VCR/WR -> VR
vrNrdNew.setContentType(rNrd.getContentType()); // P_GETCONTENTTYPE
vrNrdNew.setContentLength(rNrd.getContentLength()); //
P_GETCONTENTLENGTH
content.create( sToken, vhrUri, vrNrdNew, rNrc );
String vrUriNew = vhrUri+"/"+vrNrdNew.getRevisionNumber().toString();
- UriHandler vrUhNew = new UriHandler( nsaToken.getName(), vrUriNew );
+ UriHandler vrUhNew = UriHandler.getUriHandler( nsaToken, vrUriNew );
SubjectNode vrNodeNew = new SubjectNode();
structure.create( sToken, vrNodeNew, vrUriNew );
// set specific properties
- rNrd.removeProperty( coutProp );
- rNrd.setProperty(
- new NodeProperty(P_CHECKED_IN, pHelp.createHrefValue(vrUriNew)) );
- rNrd.removeProperty(new
NodeProperty(VersioningHelper.P_CHECKIN_LOCKTOKEN, null, true));
- rNrd.removeProperty(P_PREDECESSOR_SET);
- rNrd.removeProperty(P_CHECKOUT_FORK);
- rNrd.removeProperty(P_CHECKIN_FORK);
+ if( keepCheckedOut ) {
+ rNrd.setProperty(
+ new NodeProperty(P_CHECKED_OUT,
pHelp.createHrefValue(vrUriNew)) );
+ rNrd.setProperty(
+ new NodeProperty(P_PREDECESSOR_SET,
vrNrdNew.getProperty(P_PREDECESSOR_SET)) );
+ }
+ else {
+ if( !isWorkingResource ) {
+ rNrd.removeProperty( coutProp );
+ rNrd.setProperty(
+ new NodeProperty(P_CHECKED_IN,
pHelp.createHrefValue(vrUriNew)) );
+ rNrd.removeProperty(new
NodeProperty(VersioningHelper.P_CHECKIN_LOCKTOKEN, null, true));
+ rNrd.removeProperty(P_PREDECESSOR_SET);
+ rNrd.removeProperty(P_CHECKOUT_FORK);
+ rNrd.removeProperty(P_CHECKIN_FORK);
+ }
+ }
vhrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
vhrNrd.setProperty( new NodeProperty(
P_VERSION_SET,
((String)vSetProp.getValue())+pHelp.createHrefValue(vrUriNew)) );
- /* Content Type --end-- */
+
vrNrdNew.setName(vrUhNew.getVersionName() ); // P_DISPLAYNAME
vrNrdNew.setETag( vrUriNew.hashCode()+"_"+req.getContentLength() ); //
P_GETETAG
vrNrdNew.setCreationDate( new Date() ); // P_CREATIONDATE
+ vrNrdNew.setLastModified( new Date() ); // P_GETLASTMODIFIED
vrNrdNew.setProperty(
new NodeProperty(P_VERSION_NAME, vrUhNew.getVersionName()) );
vrNrdNew.setProperty(
new NodeProperty(P_PREDECESSOR_SET, predSetProp.getValue()) );
// Store changes
- content.store( sToken, rNrds.getUri(), rNrd, null );
//revisionContent=null
+ if( keepCheckedOut || !isWorkingResource ) {
+ content.store( sToken, rUri, rNrd, null ); //revisionContent=null
+ }
+ else {
+ // remove the WR
+ macro.delete( sToken, rUri );
+ }
content.store( sToken, vhrUri, vhrNrd, null ); //revisionContent=null
content.store( sToken, vhrUri, vrNrdNew, null ); //revisionContent=null
-
+
// Set status created
resp.setStatus( WebdavStatus.SC_CREATED );
return vrUriNew;
@@ -1061,10 +1093,16 @@
* @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
*
* @return the ViolatedPrecondition (if any).
*/
- protected ViolatedPrecondition getCheckinPreconditionViolation(NodeProperty
predSetProp, NodeRevisionDescriptors vhrNrds, boolean isForkOk) throws
LinkedObjectNotFoundException, ServiceAccessException, ObjectLockedException,
RevisionDescriptorNotFoundException, JDOMException, IllegalArgumentException,
ObjectNotFoundException, AccessDeniedException {
+ 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
+ // *********************************
ViolatedPrecondition violatedPrecondition = null;
@@ -1076,7 +1114,7 @@
String href = ((Element)iterator.next()).getText();
if (href != null) {
- UriHandler predecessorUriHandler = new UriHandler(
nsaToken.getName(), href);
+ UriHandler predecessorUriHandler = UriHandler.getUriHandler(
nsaToken, href);
// check precondition C_VERSION_HISTORY_IS_TREE
if ( !predecessorUriHandler.isVersionUri() ||
@@ -1183,6 +1221,12 @@
*/
public void update(NodeRevisionDescriptors vcrRevisionDescriptors,
NodeRevisionDescriptor vcrRevisionDescriptor, NodeRevisionDescriptors
vrRevisionDescriptors, NodeRevisionDescriptor vrRevisionDescriptor) throws
SlideException {
+ // ***************************************
+ // TODO:
+ // 1) Preconditions; Problem: not specified formally.
+ // 2) Remove Tamino-specifics; invent some kind of "store-proprietary" live
props
+ // ***************************************
+
ResourceKind vrResourceKind = VersionImpl.getInstance();
ResourceKind cinvcrResourceKind =
CheckedInVersionControlledImpl.getInstance();
String vcrUri = getUri(vcrRevisionDescriptors, vcrRevisionDescriptor);
@@ -1202,12 +1246,6 @@
vcrRevisionDescriptor.removeProperty(p);
}
- // set initial VCR properties
- Iterator iterator =
pHelp.createInitialProperties(VersionControlledImpl.getInstance()).iterator();
- while (iterator.hasNext()) {
- vcrRevisionDescriptor.setProperty((NodeProperty)iterator.next());
- }
-
// Copy all dead properties of VR to VCR
// Well, almost all ... a property named xdavContentId will be skipped ...
// Again, this is TEMPORARAY and shouldn't hurt others.
@@ -1222,7 +1260,7 @@
}
}
- // set up "special" properties
+ // update specific live properties
String vrUri = getUri(vrRevisionDescriptors, vrRevisionDescriptor);
vcrRevisionDescriptor.setProperty(new NodeProperty(P_CHECKED_IN,
pHelp.createHrefValue(vrUri)) );
@@ -1642,7 +1680,7 @@
}
else {
rNrd = content.retrieve( sToken, rNrds );
- }
+ }
return rNrd;
}
@@ -1679,13 +1717,13 @@
if ( (resourceKind instanceof VersionControlled) && (label != null) ) {
String vrUri = getUriOfAssociatedVR(nsaToken, sToken, content,
revisionDescriptors.getUri());
- UriHandler vrUriHandler = UriHandler.getUriHandler(nsaToken, vrUri);
- String historyUri = vrUriHandler.getAssociatedHistoryUri();
+ UriHandler vrUriHandler = UriHandler.getUriHandler(nsaToken, vrUri);
+ String historyUri = vrUriHandler.getAssociatedHistoryUri();
revisionDescriptors = retrieveRevisionDescriptors(nsaToken, sToken,
content, historyUri);
revisionDescriptor = retrieveLabeledRevision(nsaToken, sToken, content,
historyUri, label);
- }
- return getUri(nsaToken, sToken, content, revisionDescriptors,
revisionDescriptor);
}
+ return getUri(nsaToken, sToken, content, revisionDescriptors,
revisionDescriptor);
+ }
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>