use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class InternalVersionManagerBase method createInternalVersionItem.
/**
* Creates an {@link InternalVersionItem} based on the {@link NodeState}
* identified by <code>id</code>.
*
* @param id the node id of the version item.
* @return the version item or <code>null</code> if there is no node state
* with the given <code>id</code>.
* @throws RepositoryException if an error occurs while reading from the
* version storage.
*/
protected InternalVersionItem createInternalVersionItem(NodeId id) throws RepositoryException {
try {
if (stateMgr.hasItemState(id)) {
NodeState state = (NodeState) stateMgr.getItemState(id);
NodeStateEx pNode = new NodeStateEx(stateMgr, ntReg, state, null);
NodeId parentId = pNode.getParentId();
InternalVersionItem parent = getItem(parentId);
Name ntName = state.getNodeTypeName();
if (ntName.equals(NameConstants.NT_FROZENNODE)) {
return new InternalFrozenNodeImpl(this, pNode, parent);
} else if (ntName.equals(NameConstants.NT_VERSIONEDCHILD)) {
return new InternalFrozenVHImpl(this, pNode, parent);
} else if (ntName.equals(NameConstants.NT_VERSION)) {
return ((InternalVersionHistory) parent).getVersion(id);
} else if (ntName.equals(NameConstants.NT_VERSIONHISTORY)) {
return new InternalVersionHistoryImpl(this, pNode);
} else if (ntName.equals(NameConstants.NT_ACTIVITY)) {
return new InternalActivityImpl(this, pNode);
} else {
return null;
}
} else {
return null;
}
} catch (ItemStateException e) {
throw new RepositoryException(e);
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class VersionManagerImplBase method checkModify.
/**
* Checks modify and permissions
* @param state state to check
* @param options options to check
* @param permissions permissions to check
* @throws RepositoryException if an error occurs
*/
protected void checkModify(NodeStateEx state, int options, int permissions) throws RepositoryException {
NodeImpl node;
try {
node = session.getNodeById(state.getNodeId());
} catch (RepositoryException e) {
// ignore
return;
}
context.getItemValidator().checkModify(node, options, permissions);
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class VersionManagerImplMerge method merge.
/**
* Merge the given activity to this workspace
*
* @param activity internal activity
* @param failedIds list of failed ids
* @throws RepositoryException if an error occurs
*/
protected void merge(InternalActivity activity, List<ItemId> failedIds) throws RepositoryException {
VersionSet changeSet = activity.getChangeSet();
WriteOperation ops = startWriteOperation();
try {
Iterator<NodeId> iter = changeSet.versions().keySet().iterator();
while (iter.hasNext()) {
InternalVersion v = changeSet.versions().remove(iter.next());
NodeStateEx state = getNodeStateEx(v.getFrozenNode().getFrozenId());
if (state != null) {
InternalVersion base = getBaseVersion(state);
// but merge it anyways
if (base.isMoreRecent(v)) {
failedIds.add(state.getNodeId());
// add it to the jcr:mergeFailed property
Set<NodeId> set = getMergeFailed(state);
set.add(base.getId());
setMergeFailed(state, set);
state.store();
} else {
for (InternalVersion restored : internalRestore(state, v, changeSet, true)) {
changeSet.versions().remove(restored.getVersionHistory().getId());
}
}
}
// reset iterator
iter = changeSet.versions().keySet().iterator();
}
ops.save();
} catch (ItemStateException e) {
throw new RepositoryException(e);
} finally {
ops.close();
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class VersionHistoryImpl method removeVersion.
/**
* @see javax.jcr.version.VersionHistory#removeVersion(String)
*/
public void removeVersion(String versionName) throws UnsupportedRepositoryOperationException, VersionException, RepositoryException {
try {
// check permissions
checkVersionManagementPermission();
sessionContext.getSessionImpl().getInternalVersionManager().removeVersion(getSession(), getInternalVersionHistory(), sessionContext.getQName(versionName));
} catch (NameException e) {
throw new RepositoryException(e);
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class InternalVersionHistoryImpl method createVersionInstance.
/**
* Create a version instance.
* @param name name of the version
* @return the new internal version
* @throws IllegalArgumentException if the version does not exist
*/
synchronized InternalVersionImpl createVersionInstance(Name name) {
try {
NodeStateEx nodeStateEx = node.getNode(name, 1);
InternalVersionImpl v = createVersionInstance(nodeStateEx);
versionCache.put(v.getId(), v);
vMgr.versionCreated(v);
// add labels
for (Name labelName : labelCache.keySet()) {
Name versionName = labelCache.get(labelName);
if (v.getName().equals(versionName)) {
v.internalAddLabel(labelName);
}
}
return v;
} catch (RepositoryException e) {
throw new InconsistentVersioningState("Failed to create version " + name + " in VHR " + historyId + ".", historyId, null);
}
}
Aggregations