use of org.apache.jackrabbit.core.ItemImpl in project jackrabbit by apache.
the class CompiledPermissionsImpl method buildResult.
//------------------------------------< AbstractCompiledPermissions >---
/**
* @see AbstractCompiledPermissions#buildResult(org.apache.jackrabbit.spi.Path)
*/
@Override
protected Result buildResult(Path absPath) throws RepositoryException {
boolean existingNode = false;
NodeImpl node;
ItemManager itemMgr = session.getItemManager();
try {
ItemImpl item = itemMgr.getItem(absPath);
if (item.isNode()) {
node = (NodeImpl) item;
existingNode = true;
} else {
node = (NodeImpl) item.getParent();
}
} catch (RepositoryException e) {
// path points to a non-persisted item.
// -> find the nearest persisted node starting from the root.
Path.Element[] elems = absPath.getElements();
NodeImpl parent = (NodeImpl) session.getRootNode();
for (int i = 1; i < elems.length - 1; i++) {
Name name = elems[i].getName();
int index = elems[i].getIndex();
if (!parent.hasNode(name, index)) {
// last persisted node reached
break;
}
parent = parent.getNode(name, index);
}
node = parent;
}
if (node == null) {
// should never get here
throw new ItemNotFoundException("Item out of hierarchy.");
}
boolean isAcItem = util.isAcItem(absPath);
return buildResult(node, existingNode, isAcItem, new EntryFilterImpl(principalNames, absPath, session));
}
use of org.apache.jackrabbit.core.ItemImpl in project jackrabbit by apache.
the class SessionSaveOperation method perform.
/**
* Persists transient changes by delegating to the save() method of the
* root node (or the parent of transient changes if access to the root
* node is not available to this session).
*/
public Object perform(SessionContext context) throws RepositoryException {
NodeId id;
// JCR-2425: check whether session is allowed to read root node
if (context.getSessionImpl().hasPermission("/", Session.ACTION_READ)) {
id = context.getRootNodeId();
} else {
id = context.getItemStateManager().getIdOfRootTransientNodeState();
}
if (LOG.isDebugEnabled()) {
String path;
try {
NodeId transientRoot = context.getItemStateManager().getIdOfRootTransientNodeState();
ItemImpl item = context.getItemManager().getItem(transientRoot);
path = item.getPath();
} catch (Exception e) {
LOG.warn("Could not get the path", e);
path = "?";
}
if (LOG_WITH_STACKTRACE) {
LOG.debug("Saving changes under " + path, new Exception());
} else {
LOG.debug("Saving changes under " + path);
}
}
if (id != null) {
context.getItemManager().getItem(id).save();
}
return this;
}
Aggregations