protected ItemDefinitionTemplate( NameMapper mapper, ItemDefinition definition) throws ConstraintViolationException { super(mapper, definition.getName()); setProtected(definition.isProtected()); setMandatory(definition.isMandatory()); setAutoCreated(definition.isAutoCreated()); setOnParentVersion(definition.getOnParentVersion()); }
private static void writeItemDefinitions(@NotNull Tree nodeTypeTree, @Nullable List<? extends ItemDefinitionTemplate> itemDefTemplates, @NotNull String nodeName, @NotNull String primaryTypeName) throws RepositoryException { // first remove existing for (Tree t : filter(nodeTypeTree.getChildren(), new SameNamePredicate(nodeName))) { t.remove(); } // now write definitions int index = 1; if (itemDefTemplates != null) { for (ItemDefinitionTemplate template : itemDefTemplates) { String name = nodeName(nodeName, index); Tree tree = nodeTypeTree.getChild(name); if (!tree.exists()) { tree = nodeTypeTree.addChild(name); tree.setProperty( JCR_PRIMARYTYPE, primaryTypeName, NAME); } template.writeTo(tree); index++; } } }
/** * Writes the contents of this item definition to the given tree node. * Used when registering new node types. * * @param tree an {@code nt:propertyDefinition} or * {@code nt:childNodeDefinition} node * @throws RepositoryException if this definition could not be written */ void writeTo(Tree tree) throws RepositoryException { if (!residual) { String oakName = getOakName(); if (oakName == null) { throw new RepositoryException("Unnamed item definition"); } tree.setProperty(JCR_NAME, oakName, Type.NAME); } else { tree.removeProperty(JCR_NAME); } // TODO avoid (in validator?) unbounded recursive auto creation. // See 3.7.2.3.5 Chained Auto-creation (OAK-411) tree.setProperty(JCR_AUTOCREATED, isAutoCreated); tree.setProperty(JCR_MANDATORY, isMandatory); tree.setProperty(JCR_PROTECTED, isProtected); tree.setProperty( JCR_ONPARENTVERSION, OnParentVersionAction.nameFromValue(onParentVersion)); }
private static void writeItemDefinitions(@NotNull Tree nodeTypeTree, @Nullable List<? extends ItemDefinitionTemplate> itemDefTemplates, @NotNull String nodeName, @NotNull String primaryTypeName) throws RepositoryException { // first remove existing for (Tree t : filter(nodeTypeTree.getChildren(), new SameNamePredicate(nodeName))) { t.remove(); } // now write definitions int index = 1; if (itemDefTemplates != null) { for (ItemDefinitionTemplate template : itemDefTemplates) { String name = nodeName(nodeName, index); Tree tree = nodeTypeTree.getChild(name); if (!tree.exists()) { tree = nodeTypeTree.addChild(name); tree.setProperty( JCR_PRIMARYTYPE, primaryTypeName, NAME); } template.writeTo(tree); index++; } } }
/** * Writes the contents of this item definition to the given tree node. * Used when registering new node types. * * @param tree an {@code nt:propertyDefinition} or * {@code nt:childNodeDefinition} node * @throws RepositoryException if this definition could not be written */ void writeTo(Tree tree) throws RepositoryException { if (!residual) { String oakName = getOakName(); if (oakName == null) { throw new RepositoryException("Unnamed item definition"); } tree.setProperty(JCR_NAME, oakName, Type.NAME); } else { tree.removeProperty(JCR_NAME); } // TODO avoid (in validator?) unbounded recursive auto creation. // See 3.7.2.3.5 Chained Auto-creation (OAK-411) tree.setProperty(JCR_AUTOCREATED, isAutoCreated); tree.setProperty(JCR_MANDATORY, isMandatory); tree.setProperty(JCR_PROTECTED, isProtected); tree.setProperty( JCR_ONPARENTVERSION, OnParentVersionAction.nameFromValue(onParentVersion)); }
protected ItemDefinitionTemplate( NameMapper mapper, ItemDefinition definition) throws ConstraintViolationException { super(mapper, definition.getName()); setProtected(definition.isProtected()); setMandatory(definition.isMandatory()); setAutoCreated(definition.isAutoCreated()); setOnParentVersion(definition.getOnParentVersion()); }
private static void writeItemDefinitions(@Nonnull Tree nodeTypeTree, @CheckForNull List<? extends ItemDefinitionTemplate> itemDefTemplates, @Nonnull String nodeName, @Nonnull String primaryTypeName) throws RepositoryException { // first remove existing for (Tree t : filter(nodeTypeTree.getChildren(), new SameNamePredicate(nodeName))) { t.remove(); } // now write definitions int index = 1; if (itemDefTemplates != null) { for (ItemDefinitionTemplate template : itemDefTemplates) { String name = nodeName(nodeName, index); Tree tree = nodeTypeTree.getChild(name); if (!tree.exists()) { tree = nodeTypeTree.addChild(name); tree.setProperty( JCR_PRIMARYTYPE, primaryTypeName, NAME); } template.writeTo(tree); index++; } } }
/** * Writes the contents of this item definition to the given tree node. * Used when registering new node types. * * @param tree an {@code nt:propertyDefinition} or * {@code nt:childNodeDefinition} node * @throws RepositoryException if this definition could not be written */ void writeTo(Tree tree) throws RepositoryException { if (!residual) { String oakName = getOakName(); if (oakName == null) { throw new RepositoryException("Unnamed item definition"); } tree.setProperty(JCR_NAME, oakName, Type.NAME); } else { tree.removeProperty(JCR_NAME); } // TODO avoid (in validator?) unbounded recursive auto creation. // See 3.7.2.3.5 Chained Auto-creation (OAK-411) tree.setProperty(JCR_AUTOCREATED, isAutoCreated); tree.setProperty(JCR_MANDATORY, isMandatory); tree.setProperty(JCR_PROTECTED, isProtected); tree.setProperty( JCR_ONPARENTVERSION, OnParentVersionAction.nameFromValue(onParentVersion)); }
protected ItemDefinitionTemplate( NameMapper mapper, ItemDefinition definition) throws ConstraintViolationException { super(mapper, definition.getName()); setProtected(definition.isProtected()); setMandatory(definition.isMandatory()); setAutoCreated(definition.isAutoCreated()); setOnParentVersion(definition.getOnParentVersion()); }
/** * Writes the contents of this node definition to the given tree node. * Used when registering new node types. * * @param tree an {@code nt:childNodeDefinition} node * @throws RepositoryException if this definition could not be written */ @Override void writeTo(Tree tree) throws RepositoryException { super.writeTo(tree); tree.setProperty(JCR_SAMENAMESIBLINGS, allowSameNameSiblings); if (requiredPrimaryTypeOakNames != null) { tree.setProperty( JCR_REQUIREDPRIMARYTYPES, Arrays.asList(requiredPrimaryTypeOakNames), Type.NAMES); } else { tree.removeProperty(JCR_REQUIREDPRIMARYTYPES); } if (defaultPrimaryTypeOakName != null) { tree.setProperty( JCR_DEFAULTPRIMARYTYPE, defaultPrimaryTypeOakName, Type.NAME); } else { tree.removeProperty(JCR_DEFAULTPRIMARYTYPE); } }
/** * Writes the contents of this node definition to the given tree node. * Used when registering new node types. * * @param tree an {@code nt:childNodeDefinition} node * @throws RepositoryException if this definition could not be written */ @Override void writeTo(Tree tree) throws RepositoryException { super.writeTo(tree); tree.setProperty(JCR_SAMENAMESIBLINGS, allowSameNameSiblings); if (requiredPrimaryTypeOakNames != null) { tree.setProperty( JCR_REQUIREDPRIMARYTYPES, Arrays.asList(requiredPrimaryTypeOakNames), Type.NAMES); } else { tree.removeProperty(JCR_REQUIREDPRIMARYTYPES); } if (defaultPrimaryTypeOakName != null) { tree.setProperty( JCR_DEFAULTPRIMARYTYPE, defaultPrimaryTypeOakName, Type.NAME); } else { tree.removeProperty(JCR_DEFAULTPRIMARYTYPE); } }
/** * Writes the contents of this node definition to the given tree node. * Used when registering new node types. * * @param tree an {@code nt:childNodeDefinition} node * @throws RepositoryException if this definition could not be written */ @Override void writeTo(Tree tree) throws RepositoryException { super.writeTo(tree); tree.setProperty(JCR_SAMENAMESIBLINGS, allowSameNameSiblings); if (requiredPrimaryTypeOakNames != null) { tree.setProperty( JCR_REQUIREDPRIMARYTYPES, Arrays.asList(requiredPrimaryTypeOakNames), Type.NAMES); } else { tree.removeProperty(JCR_REQUIREDPRIMARYTYPES); } if (defaultPrimaryTypeOakName != null) { tree.setProperty( JCR_DEFAULTPRIMARYTYPE, defaultPrimaryTypeOakName, Type.NAME); } else { tree.removeProperty(JCR_DEFAULTPRIMARYTYPE); } }
super.writeTo(tree);
super.writeTo(tree);