use of javax.jcr.util.TraversingItemVisitor in project jackrabbit by apache.
the class RepositoryServiceImpl method getItemInfos.
/**
* {@inheritDoc}
*/
public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId itemId) throws ItemNotFoundException, RepositoryException {
if (!itemId.denotesNode()) {
PropertyId propertyId = (PropertyId) itemId;
PropertyInfo propertyInfo = getPropertyInfo(sessionInfo, propertyId);
return Iterators.singleton(propertyInfo);
} else {
NodeId nodeId = (NodeId) itemId;
final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
Node node = getNode(nodeId, sInfo);
Name ntName = null;
try {
ntName = sInfo.getNamePathResolver().getQName(node.getProperty(JcrConstants.JCR_PRIMARYTYPE).getString());
} catch (NameException e) {
// ignore. should never occur
}
int depth = batchReadConfig.getDepth(ntName);
if (depth == BatchReadConfig.DEPTH_DEFAULT) {
NodeInfo info;
try {
info = new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver());
} catch (NameException e) {
throw new RepositoryException(e);
}
return Collections.singletonList(info).iterator();
} else {
final List<ItemInfo> itemInfos = new ArrayList<ItemInfo>();
ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
@Override
protected void entering(Property property, int i) throws RepositoryException {
try {
itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(), getQValueFactory()));
} catch (NameException e) {
throw new RepositoryException(e);
}
}
@Override
protected void entering(Node node, int i) throws RepositoryException {
try {
itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
} catch (NameException e) {
throw new RepositoryException(e);
}
}
@Override
protected void leaving(Property property, int i) {
// nothing to do
}
@Override
protected void leaving(Node node, int i) {
// nothing to do
}
};
visitor.visit(node);
return itemInfos.iterator();
}
}
}
use of javax.jcr.util.TraversingItemVisitor in project jackrabbit-oak by apache.
the class ReadTest method assertEntry.
private void assertEntry(final int index, final boolean isAllow) throws RepositoryException {
AccessControlEntry first = AccessControlUtils.getAccessControlList(superuser, path).getAccessControlEntries()[index];
assertEquals(testUser.getPrincipal(), first.getPrincipal());
Node n = superuser.getNode("/jcr:system/rep:permissionStore/default/" + testUser.getPrincipal().getName());
TraversingItemVisitor v = new TraversingItemVisitor.Default(true, -1) {
@Override
protected void entering(Node node, int level) throws RepositoryException {
if (node.isNodeType("rep:Permissions") && node.hasProperty("rep:accessControlledPath") && path.equals(node.getProperty("rep:accessControlledPath").getString())) {
assertEquals(index, node.getProperty("rep:index").getLong());
assertEquals(isAllow, node.getProperty("rep:isAllow").getBoolean());
}
}
};
v.visit(n);
}
Aggregations