// We update the descriptor
revisionDescriptor.setRevisionNumber(newRevisionNumber);
// Fire event
if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent));
// Invoke interceptors
invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
revisionContent, PRE_STORE);
if (revisionContent != null) {
// Storing the new revision contents
objectUri.getStore()
.createRevisionContent(objectUri, revisionDescriptor,
revisionContent);
}
// Now creating the revision desriptor in the store
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
revisionDescriptor.setModificationUser(
securityHelper.getPrincipal(token).getPath().lastSegment());
objectUri.getStore()
.createRevisionDescriptor(objectUri, revisionDescriptor);
} else {
// We don't use versioning for this object.
// Two options :
// - The object already has one (and only one) revision,
// so we update it
// - The object dooesn't have any revisions right now, so we create
// the initial revision
newRevisionNumber = new NodeRevisionNumber();
revisionDescriptor.setRevisionNumber(newRevisionNumber);
if (!revisionDescriptors.hasRevisions()) {
// Fire event
if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent));
// Invoke interceptors
invokeInterceptors(token, revisionDescriptors,
revisionDescriptor,
revisionContent, PRE_STORE);
if (revisionContent != null) {
// Storing the new revision contents
objectUri.getStore()
.createRevisionContent(objectUri, revisionDescriptor,
revisionContent);
}
// Now creating the revision desriptor in the store
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
revisionDescriptor.setModificationUser(
securityHelper.getPrincipal(token).getPath().lastSegment());
objectUri.getStore()
.createRevisionDescriptor(objectUri, revisionDescriptor);
} else {
try { {
// merge the new received properties into the
// revisionDescriptor
// We update the descriptor's properties
NodeRevisionDescriptor oldRevisionDescriptor =
objectUri.getStore()
.retrieveRevisionDescriptor
(objectUri, newRevisionNumber);
Enumeration newPropertiesList =
revisionDescriptor.enumerateProperties();
while (newPropertiesList.hasMoreElements()) {
oldRevisionDescriptor
.setProperty((NodeProperty) newPropertiesList
.nextElement() );
}
// now use the merged revision descriptor
revisionDescriptor = oldRevisionDescriptor;
} // end of merge
// Fire event
if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent));
// Invoke interceptors
invokeInterceptors(token, revisionDescriptors,
revisionDescriptor,
revisionContent, PRE_STORE);
if (revisionContent != null) {
// Storing the new revision contents
try {
objectUri.getStore()
.storeRevisionContent(objectUri,
revisionDescriptor,
revisionContent);
} catch (RevisionNotFoundException e) {
objectUri.getStore()
.createRevisionContent(objectUri,
revisionDescriptor,
revisionContent);
}
}
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
revisionDescriptor.setModificationUser(
securityHelper.getPrincipal(token).getPath().lastSegment());
objectUri.getStore()
.storeRevisionDescriptor
(objectUri, revisionDescriptor);
} catch (RevisionDescriptorNotFoundException e) {
// Should NEVER happen.
// Basically, it would mean that there is no initial
// revision, which is incorrect since the object
// HAS revisions.
// Fire event
if ( ContentEvent.CREATE.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(ContentEvent.CREATE, new ContentEvent(this, token, namespace, objectUri.toString(), revisionDescriptors, revisionDescriptor, revisionContent));
// Invoke interceptors
invokeInterceptors(token, revisionDescriptors,
revisionDescriptor,
revisionContent, PRE_STORE);