use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class AccessControlManagerImpl method getPolicies.
public AccessControlPolicy[] getPolicies(String absPath) throws RepositoryException {
checkValidNodePath(absPath);
List<AccessControlList> policies = new ArrayList<AccessControlList>();
NodeState aclNode = getAclNode(absPath);
AccessControlList acl;
if (aclNode != null) {
acl = new AccessControlListImpl(aclNode, absPath, npResolver, qvf, this);
policies.add(acl);
}
return policies.toArray(new AccessControlList[policies.size()]);
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class ReorderNodes method create.
//------------------------------------------------------------< Factory >---
public static Operation create(NodeState parentState, Path srcPath, Path beforePath) throws ItemNotFoundException, RepositoryException {
// make sure the parent hierarchy entry has its child entries loaded
assertChildNodeEntries(parentState);
NodeState insert = parentState.getChildNodeState(srcPath.getName(), srcPath.getNormalizedIndex());
NodeState before = null;
if (beforePath != null) {
before = parentState.getChildNodeState(beforePath.getName(), beforePath.getNormalizedIndex());
}
return new ReorderNodes(parentState, insert, before);
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class NodeEntryImpl method notifyUUIDorMIXINModified.
/**
* Deals with modified jcr:uuid and jcr:mixinTypes property.
* See {@link #notifyUUIDorMIXINRemoved(Name)}
*
* @param child
*/
private void notifyUUIDorMIXINModified(PropertyEntry child) {
try {
if (NameConstants.JCR_UUID.equals(child.getName())) {
PropertyState ps = child.getPropertyState();
setUniqueID(ps.getValue().getString());
} else if (NameConstants.JCR_MIXINTYPES.equals(child.getName())) {
NodeState state = (NodeState) internalGetItemState();
if (state != null) {
PropertyState ps = child.getPropertyState();
state.setMixinTypeNames(StateUtility.getMixinNames(ps));
}
// nodestate not yet loaded -> ignore change
}
} catch (ItemNotFoundException e) {
log.debug("Property with name " + child.getName() + " does not exist (anymore)");
} catch (RepositoryException e) {
log.debug("Unable to access child property " + child.getName(), e.getMessage());
}
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class LockManagerImpl method getLockImpl.
/**
* Returns the Lock that applies to the given node state (directly or
* by an inherited deep lock) or <code>null</code> if the state is not
* locked at all.
*
* @param nodeState
* @param lazyLockDiscovery If true, no extra check with the server is made in order to
* determine, whether there is really no lock present. Otherwise, the server
* is asked if a lock is present.
* @return LockImpl that applies to the given state or <code>null</code>.
* @throws RepositoryException
*/
private LockImpl getLockImpl(NodeState nodeState, boolean lazyLockDiscovery) throws RepositoryException {
NodeState nState = nodeState;
// access first non-NEW state
while (nState.getStatus() == Status.NEW) {
nState = nState.getParent();
}
// shortcut: check if a given state holds a lock, which has been
// store in the lock map. see below (LockImpl) for the conditions that
// must be met in order a lock can be stored.
LockImpl l = getLockFromMap(nState);
if (l != null && l.lockState.appliesToNodeState(nodeState)) {
return l;
}
LockState lState;
if (lazyLockDiscovery) {
// try to retrieve a state (ev. a parent state) that holds a lock.
NodeState lockHoldingState = getLockHoldingState(nState);
if (lockHoldingState == null) {
// assume no lock is present (might not be correct due to incomplete hierarchy)
return null;
} else {
// check lockMap again with the lock-holding state
l = getLockFromMap(nState);
if (l != null) {
return l;
}
lState = buildLockState(lockHoldingState);
}
} else {
// need precise information about lock status -> retrieve lockInfo
// from the persistent layer.
lState = buildLockState(nState);
}
if (lState != null) {
// Test again if a Lock object is stored in the lockmap. Otherwise
// build the lock object and retrieve lock holding node. note that this
// may fail if the session does not have permission to see this node.
LockImpl lock = getLockFromMap(lState.lockHoldingState);
if (lock != null) {
lock.lockState.setLockInfo(lState.lockInfo);
} else {
Item lockHoldingNode = itemManager.getItem(lState.lockHoldingState.getHierarchyEntry());
lock = new LockImpl(lState, (Node) lockHoldingNode);
}
// test if lock applies to the original nodestate
if (lState.appliesToNodeState(nodeState)) {
return lock;
} else {
// lock exists but doesn't apply to the given state
return null;
}
} else {
// no lock at all
return null;
}
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class WorkspaceImpl method getImportContentHandler.
/**
* @see javax.jcr.Workspace#getImportContentHandler(String, int)
*/
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
session.checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
session.checkIsAlive();
Path parentPath = session.getQPath(parentAbsPath);
NodeState parentState = getHierarchyManager().getNodeState(parentPath);
// make sure the given import target is accessible, not locked and checked out.
int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
getValidator().checkIsWritable(parentState, options);
// build the content handler
return new WorkspaceContentHandler(this, parentAbsPath, uuidBehavior);
}
Aggregations