@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); } }
@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); } }
@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); } }
@Override public void unregisterNodeType(String name) throws RepositoryException { Root root = getWriteRoot(); Tree type = root.getTree(NODE_TYPES_PATH).getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } try { type.remove(); root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node type " + name; throw e.asRepositoryException(message); } }
@Override public void unregisterNodeType(String name) throws RepositoryException { Root root = getWriteRoot(); Tree type = root.getTree(NODE_TYPES_PATH).getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } try { type.remove(); root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node type " + name; throw e.asRepositoryException(message); } }
@Override public void unregisterNodeType(String name) throws RepositoryException { Root root = getWriteRoot(); Tree type = root.getTree(NODE_TYPES_PATH).getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } try { type.remove(); root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node type " + name; throw e.asRepositoryException(message); } }
@Override public void unregisterNodeTypes(String[] names) throws RepositoryException { Root root = getWriteRoot(); Tree types = root.getTree(NODE_TYPES_PATH); if (!types.exists()) { throw new NoSuchNodeTypeException("Node types can not be unregistered."); } try { for (String name : names) { Tree type = types.getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } type.remove(); } root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node types."; throw e.asRepositoryException(message); } } }
@Override public void unregisterNodeTypes(String[] names) throws RepositoryException { Root root = getWriteRoot(); Tree types = root.getTree(NODE_TYPES_PATH); if (!types.exists()) { throw new NoSuchNodeTypeException("Node types can not be unregistered."); } try { for (String name : names) { Tree type = types.getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } type.remove(); } root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node types."; throw e.asRepositoryException(message); } } }
@Override public void unregisterNodeTypes(String[] names) throws RepositoryException { Root root = getWriteRoot(); Tree types = root.getTree(NODE_TYPES_PATH); if (!types.exists()) { throw new NoSuchNodeTypeException("Node types can not be unregistered."); } try { for (String name : names) { Tree type = types.getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } type.remove(); } root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node types."; throw e.asRepositoryException(message); } } }