use of org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry in project jackrabbit by apache.
the class WorkspaceItemStateFactory method createDeepNodeState.
/**
* Creates the node with information retrieved from the <code>RepositoryService</code>.
* Intermediate entries are created as needed.
*/
public NodeState createDeepNodeState(NodeId nodeId, NodeEntry anyParent) throws ItemNotFoundException, RepositoryException {
try {
// Get item info from cache
Iterator<? extends ItemInfo> infos = null;
Entry<NodeInfo> cached = cache.getNodeInfo(nodeId);
ItemInfo info;
if (cached == null) {
// or from service if not in cache
infos = service.getItemInfos(sessionInfo, nodeId);
info = first(infos, null, 0);
if (info == null || !info.denotesNode()) {
throw new ItemNotFoundException("NodeId: " + nodeId);
}
} else {
info = cached.info;
}
// Build the hierarchy entry for the item info
HierarchyEntry entry = createHierarchyEntries(info, anyParent);
if (entry == null || !entry.denotesNode()) {
throw new ItemNotFoundException("HierarchyEntry does not belong to any existing ItemInfo. No ItemState was created.");
} else {
// Now we can check whether the item info from the cache is up to date
long generation = entry.getGeneration();
if (isOutdated(cached, entry)) {
// if not, retrieve the item info from the service and put the whole batch into the cache
infos = service.getItemInfos(sessionInfo, nodeId);
info = first(infos, cache, generation);
} else if (infos != null) {
// Otherwise put the whole batch retrieved from the service earlier into the cache
cache.put(info, generation);
first(infos, cache, generation);
}
assertMatchingPath(info, entry);
return createNodeState((NodeInfo) info, (NodeEntry) entry);
}
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(e);
}
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry in project jackrabbit by apache.
the class ItemImpl method updateId.
/**
*
* @param state
* @throws RepositoryException
*/
private static void updateId(ItemState state) throws RepositoryException {
HierarchyEntry he = state.getHierarchyEntry();
while (he.getStatus() != Status.INVALIDATED) {
he = he.getParent();
if (he == null) {
// root reached without intermediate invalidated entry
return;
}
}
// he is INVALIDATED -> force reloading in order to be aware of id changes
he.getItemState();
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry in project jackrabbit by apache.
the class Clone method persisted.
/**
* @see Operation#persisted()
*/
@Override
public void persisted() {
assert status == STATUS_PENDING;
if (removeExisting) {
status = STATUS_PERSISTED;
// invalidate the complete tree -> find root-hierarchy-entry
HierarchyEntry he = destParentState.getHierarchyEntry();
while (he.getParent() != null) {
he = he.getParent();
}
he.invalidate(true);
} else {
super.persisted();
}
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry in project jackrabbit by apache.
the class Merge method persisted.
/**
* Invalidates the target nodestate and all descendants.
*
* @see Operation#persisted()
*/
public void persisted() {
assert status == STATUS_PENDING;
status = STATUS_PERSISTED;
if (isActivityMerge()) {
// TODO be more specific about what needs to be invalidated
// look for the root entry and invalidate the complete tree
HierarchyEntry entry = nodeState.getNodeEntry();
while (entry.getParent() != null) {
entry = entry.getParent();
}
entry.invalidate(true);
} else {
try {
NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
if (vhe != null) {
vhe.invalidate(true);
}
} catch (RepositoryException e) {
log.warn("Error while retrieving VersionHistory entry: {}", e.getMessage());
}
nodeState.getHierarchyEntry().invalidate(true);
}
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry in project jackrabbit by apache.
the class RemoveActivity method persisted.
/**
* Invalidates the <code>NodeState</code> that has been updated and all
* its descendants. Second, the parent state gets invalidated.
*
* @see org.apache.jackrabbit.jcr2spi.operation.Operation#persisted()
*/
public void persisted() {
assert status == STATUS_PENDING;
status = STATUS_PERSISTED;
// invalidate all references to the removed activity
while (refs.hasNext()) {
HierarchyEntry entry = hMgr.lookup(refs.next());
if (entry != null) {
entry.invalidate(false);
}
}
// invalidate the activities parent
parent.getNodeEntry().invalidate(false);
}
Aggregations