use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class VersionableState method restoreVersionedChild.
/**
* Restore an nt:versionedChild node.
*/
private void restoreVersionedChild(NodeBuilder versionedChild, NodeBuilder dest, VersionSelector selector) throws RepositoryException, CommitFailedException {
// 15.7.5 Chained Versions on Restore
PropertyState id = versionedChild.getProperty(JCR_CHILDVERSIONHISTORY);
if (id == null) {
throw new RepositoryException("Mandatory property " + JCR_CHILDVERSIONHISTORY + " is missing.");
}
vMgr.restore(id.getValue(Type.REFERENCE), selector, dest);
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class ReadOnlyNodeTypeManager method getEffectiveNodeType.
@Override
public EffectiveNodeType getEffectiveNodeType(Tree tree) throws RepositoryException {
NodeTypeImpl primaryType;
PropertyState jcrPrimaryType = tree.getProperty(JCR_PRIMARYTYPE);
if (jcrPrimaryType != null) {
String ntName = jcrPrimaryType.getValue(STRING);
primaryType = internalGetNodeType(ntName);
} else {
throw new RepositoryException("Node at " + tree.getPath() + " has no primary type.");
}
PropertyState jcrMixinType = tree.getProperty(JCR_MIXINTYPES);
if (jcrMixinType == null) {
return new EffectiveNodeType(primaryType, this);
} else {
NodeTypeImpl[] mixinTypes = new NodeTypeImpl[jcrMixinType.count()];
for (int i = 0; i < mixinTypes.length; i++) {
mixinTypes[i] = internalGetNodeType(jcrMixinType.getValue(Type.NAME, i));
}
return new EffectiveNodeType(primaryType, mixinTypes, this);
}
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class ReadOnlyNodeTypeManager method isa.
private static boolean isa(Tree types, String typeName, String superName) {
if (typeName.equals(superName)) {
return true;
}
Tree type = types.getChild(typeName);
if (!type.exists()) {
return false;
}
PropertyState supertypes = type.getProperty(REP_SUPERTYPES);
return supertypes != null && contains(supertypes.getValue(Type.NAMES), superName);
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class ReadOnlyNodeTypeManager method isNodeType.
//------------------------------------------< EffectiveNodeTypeProvider >---
@Override
public boolean isNodeType(Tree tree, String oakNtName) {
// shortcuts for common cases
if (JcrConstants.NT_BASE.equals(oakNtName)) {
return true;
} else if (JcrConstants.MIX_REFERENCEABLE.equals(oakNtName) && !tree.hasProperty(JcrConstants.JCR_UUID)) {
return false;
} else if (JcrConstants.MIX_VERSIONABLE.equals(oakNtName) && !tree.hasProperty(JcrConstants.JCR_ISCHECKEDOUT)) {
return false;
}
Tree types = getTypes();
PropertyState primary = tree.getProperty(JcrConstants.JCR_PRIMARYTYPE);
if (primary != null && primary.getType() == Type.NAME) {
String name = primary.getValue(Type.NAME);
if (isa(types, name, oakNtName)) {
return true;
}
}
PropertyState mixins = tree.getProperty(JcrConstants.JCR_MIXINTYPES);
if (mixins != null && mixins.getType() == Type.NAMES) {
for (String name : mixins.getValue(Type.NAMES)) {
if (isa(types, name, oakNtName)) {
return true;
}
}
}
return false;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class AbstractTree method getChildNames.
/**
* Returns the list of child names considering its ordering
* when the {@link TreeConstants#OAK_CHILD_ORDER} property is set.
*
* @return the list of child names.
*/
@Nonnull
protected Iterable<String> getChildNames() {
NodeBuilder nodeBuilder = getNodeBuilder();
PropertyState order = nodeBuilder.getProperty(OAK_CHILD_ORDER);
if (order != null && order.getType() == NAMES) {
Set<String> names = newLinkedHashSet(nodeBuilder.getChildNodeNames());
List<String> ordered = newArrayListWithCapacity(names.size());
for (String name : order.getValue(NAMES)) {
// only include names of child nodes that actually exist
if (names.remove(name)) {
ordered.add(name);
}
}
// add names of child nodes that are not explicitly ordered
ordered.addAll(names);
return ordered;
} else {
return nodeBuilder.getChildNodeNames();
}
}
Aggregations