use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class InternalVersionManagerImpl method canCheckout.
/**
* {@inheritDoc}
*
* 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) {
// 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())) {
baseVersion = baseVersion.getLinearPredecessor();
}
if (baseVersion == null) {
throw new ActivityViolationException("Unable to checkout. " + "Activity is used by another version on a different branch: " + version.getName());
}
}
}
return baseId;
}
use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class InternalXAVersionManager method makeLocalCopy.
/**
* Make a local copy of an internal version item. This will recreate the
* (global) version item with state information from our own state
* manager.
* @param history source
* @return the new copy
* @throws RepositoryException if an error occurs
*/
private InternalVersionHistoryImpl makeLocalCopy(InternalVersionHistoryImpl history) throws RepositoryException {
VersioningLock.ReadLock lock = acquireReadLock();
try {
NodeState state = (NodeState) stateMgr.getItemState(history.getId());
NodeStateEx stateEx = new NodeStateEx(stateMgr, ntReg, state, null);
return new InternalVersionHistoryImpl(this, stateEx);
} catch (ItemStateException e) {
throw new RepositoryException("Unable to make local copy", e);
} finally {
lock.release();
}
}
use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class InternalXAVersionManager method makeLocalCopy.
/**
* Make a local copy of an internal version item. This will recreate the
* (global) version item with state information from our own state
* manager.
* @param act source
* @return the new copy
* @throws RepositoryException if an error occurs
*/
private InternalActivityImpl makeLocalCopy(InternalActivityImpl act) throws RepositoryException {
VersioningLock.ReadLock lock = acquireReadLock();
try {
NodeState state = (NodeState) stateMgr.getItemState(act.getId());
NodeStateEx stateEx = new NodeStateEx(stateMgr, ntReg, state, null);
return new InternalActivityImpl(this, stateEx);
} catch (ItemStateException e) {
throw new RepositoryException("Unable to make local copy", e);
} finally {
lock.release();
}
}
use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class InternalVersionManagerBase method internalCreateActivity.
/**
* Creates a new activity.
*
* @param title title of the new activity
* @return the id of the newly created activity
* @throws RepositoryException if an error occurs
*/
NodeStateEx internalCreateActivity(String title) throws RepositoryException {
WriteOperation operation = startWriteOperation();
try {
// create deep path
NodeId activityId = nodeIdFactory.newNodeId();
NodeStateEx parent = getParentNode(getActivitiesRoot(), activityId.toString(), NameConstants.REP_ACTIVITIES);
Name name = getName(activityId.toString());
// create new activity node in the persistent state
NodeStateEx pNode = InternalActivityImpl.create(parent, name, activityId, title);
// end update
operation.save();
log.debug("Created new activity " + activityId + " with title " + title + ".");
return pNode;
} catch (ItemStateException e) {
throw new RepositoryException(e);
} finally {
operation.close();
}
}
use of org.apache.jackrabbit.core.state.ItemStateException in project jackrabbit by apache.
the class VersionItemStateManager method setNodeReferences.
/**
* Sets the
* @param references
* @return
*/
public boolean setNodeReferences(ChangeLog references) {
try {
ChangeLog log = new ChangeLog();
for (NodeReferences source : references.modifiedRefs()) {
// filter out version storage intern ones
NodeReferences target = new NodeReferences(source.getTargetId());
for (PropertyId id : source.getReferences()) {
if (!hasNonVirtualItemState(id.getParentId())) {
target.addReference(id);
}
}
log.modified(target);
}
if (log.hasUpdates()) {
pMgr.store(log);
}
return true;
} catch (ItemStateException e) {
log.error("Error while setting references: " + e.toString());
return false;
}
}
Aggregations