use of javax.jcr.nodetype.NodeType in project jackrabbit-oak by apache.
the class TypeEditorProvider method isTrivialChange.
private boolean isTrivialChange(ReadOnlyNodeTypeManager ntBefore, ReadOnlyNodeTypeManager ntAfter, String nodeType) {
NodeType nb, na;
try {
nb = ntBefore.getNodeType(nodeType);
} catch (NoSuchNodeTypeException ex) {
LOG.info(nodeType + " not present in 'before' state");
return true;
} catch (RepositoryException ex) {
LOG.info("getting node type", ex);
return false;
}
try {
na = ntAfter.getNodeType(nodeType);
} catch (NoSuchNodeTypeException ex) {
LOG.info(nodeType + " was removed");
return false;
} catch (RepositoryException ex) {
LOG.info("getting node type", ex);
return false;
}
NodeTypeDefDiff diff = NodeTypeDefDiff.create(nb, na);
if (!diff.isModified()) {
LOG.info("Node type " + nodeType + " was not changed");
return true;
} else if (diff.isTrivial()) {
LOG.info("Node type change for " + nodeType + " appears to be trivial");
return true;
} else {
LOG.info("Node type change for " + nodeType + " requires repository scan: " + diff);
return false;
}
}
use of javax.jcr.nodetype.NodeType in project jackrabbit-oak by apache.
the class ReadWriteNodeTypeManager method registerNodeTypes.
@Override
public final NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate) throws RepositoryException {
Root root = getWriteRoot();
try {
Tree tree = getOrCreateNodeTypes(root);
for (NodeTypeDefinition ntd : ntds) {
NodeTypeTemplateImpl template;
if (ntd instanceof NodeTypeTemplateImpl) {
template = (NodeTypeTemplateImpl) ntd;
} else {
// some external template implementation, copy before proceeding
template = new NodeTypeTemplateImpl(getNamePathMapper(), ntd);
}
template.writeTo(tree, allowUpdate);
}
root.commit();
refresh();
List<NodeType> types = new ArrayList<NodeType>(ntds.length);
for (NodeTypeDefinition ntd : ntds) {
types.add(getNodeType(ntd.getName()));
}
return new NodeTypeIteratorAdapter(types);
} catch (CommitFailedException e) {
String message = "Failed to register node types.";
throw e.asRepositoryException(message);
}
}
use of javax.jcr.nodetype.NodeType in project jackrabbit-oak by apache.
the class NodeTypeImpl method getDeclaredSupertypes.
@Override
public NodeType[] getDeclaredSupertypes() {
NodeType[] supertypes = NO_NODE_TYPES;
String[] oakNames = getNames(JCR_SUPERTYPES);
if (oakNames != null && oakNames.length > 0) {
supertypes = new NodeType[oakNames.length];
Tree root = definition.getParent();
for (int i = 0; i < oakNames.length; i++) {
Tree type = root.getChild(oakNames[i]);
checkState(type.exists());
supertypes[i] = new NodeTypeImpl(type, mapper);
}
}
return supertypes;
}
use of javax.jcr.nodetype.NodeType in project jackrabbit-oak by apache.
the class NodeTypeImpl method internalGetPropertyDefinitions.
Collection<PropertyDefinition> internalGetPropertyDefinitions() {
// TODO distinguish between additive and overriding property definitions. See 3.7.6.8 Item Definitions in Subtypes
Collection<PropertyDefinition> definitions = new ArrayList<PropertyDefinition>();
definitions.addAll(Arrays.asList(getDeclaredPropertyDefinitions()));
for (NodeType type : getSupertypes()) {
definitions.addAll(Arrays.asList(type.getDeclaredPropertyDefinitions()));
}
return definitions;
}
use of javax.jcr.nodetype.NodeType in project jackrabbit-oak by apache.
the class EffectiveNodeType method addNodeType.
private void addNodeType(NodeTypeImpl type) {
String name = type.getName();
if (!nodeTypes.containsKey(name)) {
nodeTypes.put(name, type);
NodeType[] supertypes = type.getDeclaredSupertypes();
for (NodeType supertype : supertypes) {
// FIXME
addNodeType((NodeTypeImpl) supertype);
}
}
}
Aggregations