* this method currently does no modifications to the persistence and just
* checks if the checkout is valid in respect to a possible activity set on
* the session
*/
public NodeId canCheckout(NodeStateEx state, NodeId activityId) throws RepositoryException {
NodeId baseId = state.getPropertyValue(NameConstants.JCR_BASEVERSION).getNodeId();
if (activityId != null) {
// If there exists another workspace with node N' where N' also has version
// history H, N' is checked out and the jcr:activity property of N'
// references A, then the checkout fails with an
// ActivityViolationException indicating which workspace currently has
// the checkout.
// we're currently leverage the fact, that only references to "real"
// workspaces are recorded. so check all references if their sources
// exist in 'this' workspace
if (stateMgr.hasNodeReferences(activityId)) {
try {
NodeReferences refs = stateMgr.getNodeReferences(activityId);
for (PropertyId id: refs.getReferences()) {
if (!state.hasNode(id.getParentId())) {
throw new ActivityViolationException("Unable to checkout. " +
"Activity is already used for the same node in " +
"another workspace.");
}
}
} catch (ItemStateException e) {
throw new RepositoryException("Error during checkout.", e);
}
}
// If there is a version in H that is not an eventual predecessor of N but
// whose jcr:activity references A, then the checkout fails with an
// ActivityViolationException
InternalActivityImpl a = (InternalActivityImpl) getItem(activityId);
NodeId historyId = state.getPropertyValue(NameConstants.JCR_VERSIONHISTORY).getNodeId();
InternalVersionHistory history = (InternalVersionHistory) getItem(historyId);
InternalVersion version = a.getLatestVersion(history);
if (version != null) {
InternalVersion baseVersion = (InternalVersion) getItem(baseId);
while (baseVersion != null && !baseVersion.getId().equals(version.getId())) {