use of org.apache.jackrabbit.spi.ItemInfo 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.spi.ItemInfo in project jackrabbit by apache.
the class WorkspaceItemStateFactory method createPropertyState.
/**
* Creates the PropertyState with information retrieved from the <code>RepositoryService</code>.
*/
public PropertyState createPropertyState(PropertyId propertyId, PropertyEntry entry) throws ItemNotFoundException, RepositoryException {
try {
// Get item info from cache and use it if up to date
Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
ItemInfo info;
if (isUpToDate(cached, entry)) {
info = cached.info;
} else {
// otherwise retrieve item info from service and cache the whole batch
Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo, propertyId);
info = first(infos, cache, entry.getGeneration());
if (info == null || info.denotesNode()) {
throw new ItemNotFoundException("PropertyId: " + propertyId);
}
}
assertMatchingPath(info, entry);
return createPropertyState((PropertyInfo) info, entry);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(e);
}
}
use of org.apache.jackrabbit.spi.ItemInfo in project jackrabbit by apache.
the class WorkspaceItemStateFactory method createNodeState.
/**
* Creates the node with information retrieved from the <code>RepositoryService</code>.
*/
public NodeState createNodeState(NodeId nodeId, NodeEntry entry) throws ItemNotFoundException, RepositoryException {
try {
Entry<NodeInfo> cached = cache.getNodeInfo(nodeId);
ItemInfo info;
if (isUpToDate(cached, entry)) {
info = cached.info;
} else {
// otherwise retrieve item info from service and cache the whole batch
Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo, nodeId);
info = first(infos, cache, entry.getGeneration());
if (info == null || !info.denotesNode()) {
throw new ItemNotFoundException("NodeId: " + nodeId);
}
}
assertMatchingPath(info, entry);
return createNodeState((NodeInfo) info, entry);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(e);
}
}
use of org.apache.jackrabbit.spi.ItemInfo in project jackrabbit by apache.
the class GetItemsTest method checkHierarchy.
private void checkHierarchy() throws PathNotFoundException, RepositoryException, ItemNotFoundException, AccessDeniedException {
for (Iterator<ItemInfo> itemInfos = itemInfoStore.getItemInfos(); itemInfos.hasNext(); ) {
ItemInfo itemInfo = itemInfos.next();
String jcrPath = toJCRPath(itemInfo.getPath());
Item item = session.getItem(jcrPath);
assertEquals(jcrPath, item.getPath());
if (item.getDepth() > 0) {
Node parent = item.getParent();
if (item.isNode()) {
assertTrue(item.isSame(parent.getNode(item.getName())));
} else {
assertTrue(item.isSame(parent.getProperty(item.getName())));
}
}
}
}
use of org.apache.jackrabbit.spi.ItemInfo in project jackrabbit by apache.
the class RepositoryServiceImpl method getItemInfos.
@Override
public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId itemId) throws RepositoryException {
// currently: missing prop-names with child-NodeInfo
if (itemId.denotesNode()) {
List<ItemInfo> l = new ArrayList<ItemInfo>();
NodeInfo nInfo = getNodeInfo(sessionInfo, (NodeId) itemId);
l.add(nInfo);
// at least add propertyInfos for the meta-props already known from the
// nodeInfo.
l.addAll(buildPropertyInfos(nInfo));
return l.iterator();
} else {
PropertyInfo pInfo = getPropertyInfo(sessionInfo, (PropertyId) itemId);
return Iterators.singleton(pInfo);
}
}
Aggregations