use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class NodeCounterEditor method leaveOld.
private void leaveOld(NodeState before, NodeState after) throws CommitFailedException {
long offset = ApproximateCounter.calculateOffset(countOffset, root.resolution);
if (offset == 0) {
return;
}
// only read the value of the property if really needed
NodeBuilder builder = getBuilder();
PropertyState p = builder.getProperty(COUNT_PROPERTY_NAME);
long count = p == null ? 0 : p.getValue(Type.LONG);
offset = ApproximateCounter.adjustOffset(count, offset, root.resolution);
if (offset == 0) {
return;
}
count += offset;
root.callback.indexUpdate();
if (count == 0) {
if (builder.getChildNodeCount(1) >= 0) {
builder.removeProperty(COUNT_PROPERTY_NAME);
} else {
builder.remove();
}
} else {
builder.setProperty(COUNT_PROPERTY_NAME, count);
}
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class NodeCounter method getEstimatedNodeCountOld.
private static long getEstimatedNodeCountOld(NodeState root, NodeState s, String path, boolean max) {
// old code from here
PropertyState p = s.getProperty(NodeCounterEditor.COUNT_PROPERTY_NAME);
if (p != null) {
long x = p.getValue(Type.LONG);
if (max) {
// in the node itself, we just add the resolution
x += ApproximateCounter.COUNT_RESOLUTION;
}
return x;
}
// check in the counter index (if it exists)
s = child(root, IndexConstants.INDEX_DEFINITIONS_NAME, "counter");
if (s == null || !s.exists()) {
// no index
return -1;
}
s = child(s, NodeCounterEditor.DATA_NODE_NAME);
if (!s.exists()) {
// no index data (not yet indexed, or very few nodes)
return -1;
}
s = child(s, PathUtils.elements(path));
if (s == null || !s.exists()) {
// we have an index, but no data
long x = 0;
if (max) {
// in the index, the resolution is lower
x += ApproximateCounter.COUNT_RESOLUTION * 20;
}
return x;
}
p = s.getProperty(NodeCounterEditor.COUNT_PROPERTY_NAME);
if (p == null) {
// we have an index, but no data
long x = 0;
if (max) {
// in the index, the resolution is lower
x += ApproximateCounter.COUNT_RESOLUTION * 20;
}
return x;
}
long x = p.getValue(Type.LONG);
if (max) {
x += ApproximateCounter.COUNT_RESOLUTION;
}
return x;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class PrivilegeUtil method readDefinition.
/**
* Reads the privilege definition stored in the specified definition tree.
* Note, that this utility does not check the existence nor the node type
* of the specified tree.
*
* @param definitionTree An existing tree storing a privilege definition.
* @return A new instance of {@code PrivilegeDefinition}.
*/
@Nonnull
public static PrivilegeDefinition readDefinition(@Nonnull Tree definitionTree) {
String name = definitionTree.getName();
boolean isAbstract = TreeUtil.getBoolean(definitionTree, REP_IS_ABSTRACT);
Iterable<String> declAggrNames = null;
PropertyState property = definitionTree.getProperty(REP_AGGREGATES);
if (property != null) {
declAggrNames = property.getValue(Type.NAMES);
}
return new ImmutablePrivilegeDefinition(name, isAbstract, declAggrNames);
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class AbstractRestrictionProvider method getRestrictionProperties.
@Nonnull
private Map<String, PropertyState> getRestrictionProperties(Tree aceTree) {
Tree rTree = getRestrictionsTree(aceTree);
Map<String, PropertyState> restrictionProperties = new HashMap<String, PropertyState>();
for (PropertyState property : rTree.getProperties()) {
String name = property.getName();
if (isRestrictionProperty(name)) {
restrictionProperties.put(name, property);
}
}
return restrictionProperties;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class UserPrincipalProvider method getPrincipalName.
@CheckForNull
private static String getPrincipalName(@Nonnull Tree tree) {
PropertyState principalName = tree.getProperty(UserConstants.REP_PRINCIPAL_NAME);
if (principalName != null) {
return principalName.getValue(STRING);
} else {
String msg = "Authorizable without principal name " + UserUtil.getAuthorizableId(tree);
log.warn(msg);
return null;
}
}
Aggregations