use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class JcrVersionManager method removeActivity.
/**
* @see javax.jcr.version.VersionManager#removeActivity(Node)
*/
public void removeActivity(Node activityNode) throws UnsupportedRepositoryOperationException, RepositoryException {
session.checkIsAlive();
NodeImpl activity = getValidActivity(activityNode, "remove");
NodeState nState = (NodeState) activity.getItemState();
ItemId removeId = nState.getId();
vMgr.removeActivity(nState);
// setting on this session, that points to the removed activity.
if (activityId != null && activityId.equals(removeId)) {
activityId = null;
}
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class ItemManagerImpl method getItem.
/**
* @see ItemManager#getItem(HierarchyEntry)
*/
public Item getItem(HierarchyEntry hierarchyEntry) throws ItemNotFoundException, RepositoryException {
session.checkIsAlive();
ItemState state = hierarchyEntry.getItemState();
if (!state.isValid()) {
throw new ItemNotFoundException(LogUtil.safeGetJCRPath(state, session.getPathResolver()));
}
// first try to access item from cache
Item item = itemCache.getItem(state);
// not yet in cache, need to create instance
if (item == null) {
// create instance of item
if (hierarchyEntry.denotesNode()) {
item = createNodeInstance((NodeState) state);
} else {
item = createPropertyInstance((PropertyState) state);
}
}
return item;
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class SessionImporter method resolveUUIDConflict.
//----------------------------------------------------< Private methods >---
/**
* @param parent
* @param conflicting
* @param nodeInfo
* @return
* @throws RepositoryException
*/
NodeState resolveUUIDConflict(NodeState parent, NodeEntry conflicting, NodeInfo nodeInfo) throws ItemExistsException, RepositoryException {
NodeState nodeState;
switch(uuidBehavior) {
case ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW:
String originalUUID = nodeInfo.getUUID();
String newUUID = UUID.randomUUID().toString();
// reset id on nodeInfo to force creation with new uuid:
nodeInfo.setUUID(newUUID);
nodeState = importNode(nodeInfo, parent);
if (nodeState != null) {
// remember uuid mapping
refTracker.mappedUUIDs(originalUUID, newUUID);
}
break;
case ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW:
String msg = "a node with uuid " + nodeInfo.getUUID() + " already exists!";
log.debug(msg);
throw new ItemExistsException(msg);
case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING:
// make sure conflicting node is not importTarget or an ancestor thereof
Path p0 = importTarget.getPath();
Path p1 = conflicting.getPath();
if (p1.equals(p0) || p1.isAncestorOf(p0)) {
msg = "cannot remove ancestor node";
log.debug(msg);
throw new ConstraintViolationException(msg);
}
// do remove conflicting (recursive) including validation check
try {
Operation op = Remove.create(conflicting.getNodeState());
stateMgr.execute(op);
} catch (ItemNotFoundException e) {
// conflicting does not exist any more. no need for a removal
}
// create new with given uuid:
nodeState = importNode(nodeInfo, parent);
break;
case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING:
if (conflicting.getNodeState().isRoot()) {
msg = "Root node cannot be replaced";
log.debug(msg);
throw new RepositoryException(msg);
}
// 'replace' current parent with parent of conflicting
parent = conflicting.getParent().getNodeState();
// do remove conflicting (recursive), including validation checks
Operation op = Remove.create(conflicting.getNodeState());
stateMgr.execute(op);
// create new with given uuid at same location as conflicting
nodeState = importNode(nodeInfo, parent);
break;
default:
msg = "Unknown uuidBehavior: " + uuidBehavior;
log.debug(msg);
throw new RepositoryException(msg);
}
return nodeState;
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class AccessControlManagerImpl method removePolicy.
public void removePolicy(String absPath, AccessControlPolicy policy) throws RepositoryException {
checkValidNodePath(absPath);
checkValidPolicy(policy);
NodeState aclNode = getAclNode(absPath);
if (aclNode != null) {
removeNode(aclNode);
} else {
throw new AccessControlException("No policy exist at " + absPath);
}
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class AccessControlManagerImpl method getApplicable.
//--------------------------------------------------< private >---
private AccessControlPolicy[] getApplicable(String absPath) throws RepositoryException {
NodeState controlledState;
if (absPath == null) {
controlledState = getRootNodeState();
} else {
controlledState = getNodeState(absPath);
}
AccessControlPolicy acl = null;
NodeState aclNode = getAclNode(controlledState, absPath);
if (aclNode == null) {
acl = new AccessControlListImpl(absPath, npResolver, qvf);
}
return (acl == null) ? new AccessControlPolicy[0] : new AccessControlPolicy[] { acl };
}
Aggregations