use of org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate in project jackrabbit-oak by apache.
the class LockOperation method performVoid.
@Override
public void performVoid() throws RepositoryException {
session.refresh(true);
NodeDelegate node = session.getNode(path);
if (node != null) {
performVoid(node);
} else {
throw new PathNotFoundException("Node " + path + " not found");
}
}
use of org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate in project jackrabbit-oak by apache.
the class LockOperation method perform.
@Nonnull
@Override
public T perform() throws RepositoryException {
session.refresh(true);
NodeDelegate node = session.getNode(path);
if (node != null) {
return perform(node);
} else {
throw new PathNotFoundException("Node " + path + " not found");
}
}
use of org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate in project jackrabbit-oak by apache.
the class SessionImpl method getItemInternal.
@CheckForNull
private ItemImpl<?> getItemInternal(@Nonnull String oakPath) throws RepositoryException {
checkAlive();
ItemDelegate item = sd.getItem(oakPath);
if (item instanceof NodeDelegate) {
return NodeImpl.createNode((NodeDelegate) item, sessionContext);
} else if (item instanceof PropertyDelegate) {
return new PropertyImpl((PropertyDelegate) item, sessionContext);
} else {
return null;
}
}
use of org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate in project jackrabbit-oak by apache.
the class VersionManagerImpl method restore.
@Override
public void restore(final String absPath, final Version version, final boolean removeExisting) throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
sessionDelegate.performVoid(new SessionOperation<Void>("restore", true) {
@Override
public void performVoid() throws RepositoryException {
String oakPath = getOakPathOrThrowNotFound(absPath);
NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
if (nodeDelegate != null) {
throw new VersionException("VersionManager.restore(String, Version, boolean)" + " not allowed on existing nodes; use" + " VersionManager.restore(Version, boolean) instead: " + absPath);
}
// check if parent exists
NodeDelegate parent = ensureParentExists(sessionDelegate, absPath);
// check for pending changes
checkPendingChangesForRestore(sessionDelegate);
// check lock status
checkNotLocked(parent.getPath());
// check for existing nodes
List<NodeDelegate> existing = getExisting(version, Collections.<String>emptySet());
boolean success = false;
try {
if (!existing.isEmpty()) {
if (removeExisting) {
removeExistingNodes(existing);
} else {
List<String> paths = new ArrayList<String>();
for (NodeDelegate nd : existing) {
paths.add(nd.getPath());
}
throw new ItemExistsException("Unable to restore with " + "removeExisting=false. Existing nodes in " + "workspace: " + paths);
}
}
// ready for restore
VersionDelegate vd = versionManagerDelegate.getVersionByIdentifier(version.getIdentifier());
versionManagerDelegate.restore(parent, PathUtils.getName(oakPath), vd);
sessionDelegate.commit();
success = true;
} catch (CommitFailedException e) {
throw e.asRepositoryException();
} finally {
if (!success) {
// refresh if one of the modifying operations fail
sessionDelegate.refresh(false);
}
}
}
});
}
use of org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate in project jackrabbit-oak by apache.
the class VersionManagerImpl method checkout.
@Override
public void checkout(final String absPath) throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
sessionDelegate.performVoid(new SessionOperation<Void>("checkout", true) {
@Override
public void performVoid() throws RepositoryException {
String oakPath = getOakPathOrThrowNotFound(absPath);
NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
if (nodeDelegate == null) {
throw new PathNotFoundException(absPath);
}
checkNotLocked(absPath);
versionManagerDelegate.checkout(nodeDelegate);
}
});
}
Aggregations