use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class SameNameSiblingsEditor method prepareChildDefsWithoutSns.
/**
* Prepare a list of node definitions that doesn't allow having SNS children.
*
* @param root Repository root
* @return a list of node definitions denying SNS children
*/
private static List<ChildTypeDef> prepareChildDefsWithoutSns(NodeState root) {
List<ChildTypeDef> defs = new ArrayList<ChildTypeDef>();
NodeState types = root.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
for (ChildNodeEntry typeEntry : types.getChildNodeEntries()) {
NodeState type = typeEntry.getNodeState();
TypePredicate typePredicate = new TypePredicate(root, typeEntry.getName());
defs.addAll(parseResidualChildNodeDefs(root, type, typePredicate));
defs.addAll(parseNamedChildNodeDefs(root, type, typePredicate));
}
return defs;
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class VersionHistoryUtil method getVersionableNodes.
private static void getVersionableNodes(NodeState node, NodeState versionStorage, TypePredicate isVersionable, Calendar olderThan, String path, List<String> paths) {
if (isVersionable.apply(node)) {
if (olderThan == null) {
paths.add(path);
} else {
NodeState versionHistory = getVersionHistoryNodeState(versionStorage, node.getString(JCR_UUID));
Calendar lastModified = getVersionHistoryLastModified(versionHistory);
if (lastModified.before(olderThan)) {
paths.add(path);
}
}
}
for (ChildNodeEntry c : node.getChildNodeEntries()) {
getVersionableNodes(c.getNodeState(), versionStorage, isVersionable, olderThan, PathUtils.concat(path, c.getName()), paths);
}
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class IndexDefinitionUpdaterTest method createIndexDefn.
private String createIndexDefn(NodeState nodeState, String... indexPaths) throws CommitFailedException {
NodeStore store = new MemoryNodeStore();
NodeBuilder builder = store.getRoot().builder();
for (ChildNodeEntry cne : nodeState.getChildNodeEntries()) {
builder.setChildNode(cne.getName(), cne.getNodeState());
}
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
IndexDefinitionPrinter printer = new IndexDefinitionPrinter(store, () -> asList(indexPaths));
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
printer.print(pw, Format.JSON, false);
pw.flush();
return sw.toString();
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class DepthFirstNodeIterator method switchRoot.
public DepthFirstNodeIterator switchRoot(NodeState newRoot) {
Deque<Iterator<? extends ChildNodeEntry>> newQueue = new ArrayDeque<>();
NodeState current = newRoot;
for (String name : nameQueue) {
boolean found = false;
Iterator<? extends ChildNodeEntry> it = current.getChildNodeEntries().iterator();
newQueue.add(it);
while (it.hasNext()) {
ChildNodeEntry e = it.next();
if (name.equals(e.getName())) {
current = e.getNodeState();
found = true;
break;
}
}
if (!found) {
log.warn("Can't found {} in the new root. Switching to /", getPath());
return new DepthFirstNodeIterator(newRoot);
}
}
newQueue.add(current.getChildNodeEntries().iterator());
return new DepthFirstNodeIterator(newRoot, newQueue, nameQueue);
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class UniqueIndexCleaner method clean.
public int clean(NodeBuilder builder, long lastIndexedTo) {
int removalCount = 0;
NodeState baseState = builder.getBaseState();
for (ChildNodeEntry e : baseState.getChildNodeEntries()) {
long entryCreationTime = e.getNodeState().getLong(PROP_CREATED);
if (entryCovered(entryCreationTime, lastIndexedTo)) {
builder.child(e.getName()).remove();
removalCount++;
}
}
return removalCount;
}
Aggregations