use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class SegmentCheckpointMBean method collectCheckpoints.
@Override
protected void collectCheckpoints(TabularDataSupport tab) throws OpenDataException {
for (ChildNodeEntry cne : store.getCheckpoints().getChildNodeEntries()) {
String id = cne.getName();
NodeState checkpoint = cne.getNodeState();
String created = getDate(checkpoint, "created");
String expires = getDate(checkpoint, "timestamp");
tab.put(id, toCompositeData(id, created, expires, store.checkpointInfo(id)));
}
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class JsonSerializer method serialize.
public void serialize(NodeState node) {
json.object();
for (PropertyState property : node.getProperties()) {
String name = property.getName();
if (filter.includeProperty(name)) {
json.key(name);
serialize(property);
}
}
if (filter.includeProperty(":childNodeCount")) {
json.key(":childNodeCount");
json.value(node.getChildNodeCount(Integer.MAX_VALUE));
}
int index = 0;
int count = 0;
for (ChildNodeEntry child : node.getChildNodeEntries()) {
String name = child.getName();
if (filter.includeNode(name) && index++ >= offset) {
if (count++ >= maxChildNodes) {
break;
}
json.key(name);
if (depth > 0) {
getChildSerializer().serialize(child.getNodeState());
} else {
json.object();
json.endObject();
}
}
}
json.endObject();
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class MemoryNodeState method wrap.
static MemoryNodeState wrap(NodeState state) {
if (state instanceof MemoryNodeState) {
return (MemoryNodeState) state;
}
Map<String, PropertyState> properties = newHashMap();
for (PropertyState property : state.getProperties()) {
properties.put(property.getName(), property);
}
Map<String, NodeState> nodes = newHashMap();
for (ChildNodeEntry child : state.getChildNodeEntries()) {
nodes.put(child.getName(), child.getNodeState());
}
return new MemoryNodeState(properties, nodes);
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class MemoryNodeState method compareAgainstBaseState.
/**
* We don't keep track of a separate base node state for
* {@link MemoryNodeState} instances, so this method will just do
* a generic diff against the given state.
*/
@Override
public boolean compareAgainstBaseState(NodeState base, NodeStateDiff diff) {
if (base == EMPTY_NODE || !base.exists()) {
return EmptyNodeState.compareAgainstEmptyState(this, diff);
}
Map<String, PropertyState> newProperties = new HashMap<String, PropertyState>(properties);
for (PropertyState before : base.getProperties()) {
PropertyState after = newProperties.remove(before.getName());
if (after == null) {
if (!diff.propertyDeleted(before)) {
return false;
}
} else if (!after.equals(before)) {
if (!diff.propertyChanged(before, after)) {
return false;
}
}
}
for (PropertyState after : newProperties.values()) {
if (!diff.propertyAdded(after)) {
return false;
}
}
Map<String, NodeState> newNodes = new HashMap<String, NodeState>(nodes);
for (ChildNodeEntry entry : base.getChildNodeEntries()) {
String name = entry.getName();
NodeState before = entry.getNodeState();
NodeState after = newNodes.remove(name);
if (after == null) {
if (!diff.childNodeDeleted(name, before)) {
return false;
}
} else if (after != before) {
if (!diff.childNodeChanged(name, before, after)) {
return false;
}
}
}
for (Map.Entry<String, NodeState> entry : newNodes.entrySet()) {
if (!diff.childNodeAdded(entry.getKey(), entry.getValue())) {
return false;
}
}
return true;
}
use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.
the class BundledTypesRegistry method from.
public static BundledTypesRegistry from(NodeState configParentState) {
Map<String, DocumentBundlor> bundlors = Maps.newHashMap();
for (ChildNodeEntry e : configParentState.getChildNodeEntries()) {
NodeState config = e.getNodeState();
if (config.getBoolean(DocumentBundlor.PROP_DISABLED)) {
continue;
}
bundlors.put(e.getName(), DocumentBundlor.from(config));
}
return new BundledTypesRegistry(bundlors);
}
Aggregations