use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.
the class VersionManagerImpl method createConfiguration.
/**
* {@inheritDoc}
*/
public Node createConfiguration(String absPath) throws RepositoryException {
if (session.nodeExists(absPath)) {
NodeStateEx state = getNodeState(absPath, ItemValidator.CHECK_LOCK | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE | ItemValidator.CHECK_HOLD, Permission.VERSION_MNGMT);
// check versionable
if (!checkVersionable(state)) {
throw new UnsupportedRepositoryOperationException("Node not full versionable: " + absPath);
}
if (state.getPropertyValue(NameConstants.JCR_CONFIGURATION) != null) {
String msg = "Node is already a configuration root: " + absPath;
log.error(msg);
throw new UnsupportedRepositoryOperationException(msg);
}
NodeId configId = createConfiguration(state);
return session.getNodeById(configId);
} else {
String msg = "Create configuration node must exist: " + absPath;
log.error(msg);
throw new UnsupportedRepositoryOperationException(msg);
}
}
use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.
the class VersionManagerImpl method mergeOrUpdate.
/**
* Combines merge and update method
* @param state the state to merge or update
* @param srcWorkspaceName source workspace name
* @param failedIds list that will contain the failed ids.
* if <code>null</code> and update will be performed.
* @param bestEffort best effort flag
* @param isShallow is shallow flag
* @throws RepositoryException if an error occurs
*/
private void mergeOrUpdate(NodeStateEx state, String srcWorkspaceName, List<ItemId> failedIds, boolean bestEffort, boolean isShallow) throws RepositoryException {
// if same workspace, ignore
if (!srcWorkspaceName.equals(session.getWorkspace().getName())) {
// check authorization for specified workspace
if (!session.getAccessManager().canAccess(srcWorkspaceName)) {
String msg = "not authorized to access " + srcWorkspaceName;
log.error(msg);
throw new AccessDeniedException(msg);
}
// get root node of src workspace
SessionImpl srcSession = null;
try {
// create session on other workspace for current subject
// (may throw NoSuchWorkspaceException and AccessDeniedException)
srcSession = ((RepositoryImpl) session.getRepository()).createSession(session.getSubject(), srcWorkspaceName);
WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();
NodeId rootNodeId = ((NodeImpl) srcSession.getRootNode()).getNodeId();
NodeStateEx srcRoot = new NodeStateEx(srcWsp.getItemStateManager(), ntReg, rootNodeId);
merge(state, srcRoot, failedIds, bestEffort, isShallow);
} catch (ItemStateException e) {
throw new RepositoryException(e);
} finally {
if (srcSession != null) {
// we don't need the other session anymore, logout
srcSession.logout();
}
}
}
}
use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.
the class VersionManagerImpl method cancelMerge.
/**
* {@inheritDoc}
*/
public void cancelMerge(String absPath, Version version) throws RepositoryException {
NodeStateEx state = getNodeState(absPath, ItemValidator.CHECK_LOCK | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE | ItemValidator.CHECK_HOLD, Permission.VERSION_MNGMT);
finishMerge(state, version, true);
}
use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.
the class VersionManagerImpl method doneMerge.
/**
* {@inheritDoc}
*/
public void doneMerge(String absPath, Version version) throws RepositoryException {
NodeStateEx state = getNodeState(absPath, ItemValidator.CHECK_LOCK | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE | ItemValidator.CHECK_HOLD, Permission.VERSION_MNGMT);
finishMerge(state, version, false);
}
use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.
the class VersionManagerImpl method restore.
/**
* Same as {@link #restore(String, String, boolean)} but to ensure
* backward compatibility for Node.restore(Version, boolean).
*
* @param node the node to restore
* @param version the version to restore
* @param removeExisting the remove existing flag
* @throws RepositoryException if an error occurs
*/
protected void restore(NodeImpl node, Version version, boolean removeExisting) throws RepositoryException {
NodeStateEx state = getNodeState(node.getPath(), CHECK_PENDING_CHANGES | CHECK_LOCK | CHECK_HOLD, Permission.NONE);
InternalVersion v = getVersion(version);
restore(state, v, removeExisting);
}
Aggregations