private boolean isChildNameInDefList(String name) { for (NodeDefinition nd : getChildNodeDefinitions()) { if (name.equals(nd.getName())) { return true; } } return false; }
/** * Returns a name that is not defined by the nodeType's child node def */ public static String getUndefinedChildNodeName(NodeType nodeType) { NodeDefinition nodeDefs[] = nodeType.getChildNodeDefinitions(); StringBuffer s = new StringBuffer("X"); for (int i = 0; i < nodeDefs.length; i++) { s.append(nodeDefs[i].getName()); } String undefinedName = s.toString(); undefinedName = undefinedName.replaceAll("\\*", ""); undefinedName = undefinedName.replaceAll(":", ""); return undefinedName; }
private void addNodeType(NodeDefinition nd, NodeType nt) { Collection<String> types = namesToTypes.get(nd.getName()); if (types == null) { types = new HashSet<String>(5); namesToTypes.put(nd.getName(), types); } types.add(nt.getName()); Collection<String> names = typesToNames.get(nt.getName()); if (names == null) { names = new HashSet<String>(5); typesToNames.put(nt.getName(), names); } names.add(nd.getName()); } }
private String lookupFilename(final Node node) throws RepositoryException { String filename = JcrUtils.getStringProperty(node, HippoNodeType.HIPPO_FILENAME, null); if (StringUtils.isEmpty(filename)) { if (node.getDefinition().getName().equals("*")) { filename = node.getName(); } else { filename = node.getParent().getName(); } } return filename; }
public boolean canRemoveNode(String s) { boolean canRemoveNd = true; Iterator it = ntd.getNodeDefinitionTemplates().iterator(); NodeDefinition nd = null; while (it.hasNext()) { nd = (NodeDefinitionTemplate) it.next(); if ((nd != null) && (nd.getName().equals(s)) && (nd.isProtected() || nd.isMandatory())) { canRemoveNd = false; return canRemoveNd; } } return canRemoveNd; }
NodeDefinitionId(NodeDefinition def) { declaringNodeType = def.getDeclaringNodeType().getName(); name = def.getName(); }
NodeDefinitionId(NodeDefinition def) { declaringNodeType = def.getDeclaringNodeType().getName(); name = def.getName(); }
NodeDefinitionId(NodeDefinition def) { declaringNodeType = def.getDeclaringNodeType().getName(); name = def.getName(); }
private void processChildNodeDefinition( Node nodeTypeNode, NodeDefinition childNodeDefinition ) throws RepositoryException { Node childNode = nodeTypeNode.addNode(CHILD_NODE_DEFINITION, CHILD_NODE_DEFINITION); if (!RESIDUAL_ITEM_NAME.equals(childNodeDefinition.getName())) { childNode.setProperty(NAME, childNodeDefinition.getName()); } childNode.setProperty(AUTO_CREATED, childNodeDefinition.isAutoCreated()); childNode.setProperty(MANDATORY, childNodeDefinition.isMandatory()); childNode.setProperty(ON_PARENT_VERSION, OnParentVersionAction.nameFromValue(childNodeDefinition.getOnParentVersion())); childNode.setProperty(PROTECTED, childNodeDefinition.isProtected()); String[] requiredPrimaryTypeNames = childNodeDefinition.getRequiredPrimaryTypeNames(); childNode.setProperty(REQUIRED_PRIMARY_TYPES, requiredPrimaryTypeNames != null ? requiredPrimaryTypeNames : new String[0]); childNode.setProperty(SAME_NAME_SIBLINGS, childNodeDefinition.allowsSameNameSiblings()); childNode.setProperty(DEFAULT_PRIMARY_TYPE, childNodeDefinition.getDefaultPrimaryTypeName()); }
private void processChildNodeDefinition( Node nodeTypeNode, NodeDefinition childNodeDefinition ) throws RepositoryException { Node childNode = nodeTypeNode.addNode(CHILD_NODE_DEFINITION, CHILD_NODE_DEFINITION); if (!RESIDUAL_ITEM_NAME.equals(childNodeDefinition.getName())) { childNode.setProperty(NAME, childNodeDefinition.getName()); } childNode.setProperty(AUTO_CREATED, childNodeDefinition.isAutoCreated()); childNode.setProperty(MANDATORY, childNodeDefinition.isMandatory()); childNode.setProperty(ON_PARENT_VERSION, OnParentVersionAction.nameFromValue(childNodeDefinition.getOnParentVersion())); childNode.setProperty(PROTECTED, childNodeDefinition.isProtected()); String[] requiredPrimaryTypeNames = childNodeDefinition.getRequiredPrimaryTypeNames(); childNode.setProperty(REQUIRED_PRIMARY_TYPES, requiredPrimaryTypeNames != null ? requiredPrimaryTypeNames : new String[0]); childNode.setProperty(SAME_NAME_SIBLINGS, childNodeDefinition.allowsSameNameSiblings()); childNode.setProperty(DEFAULT_PRIMARY_TYPE, childNodeDefinition.getDefaultPrimaryTypeName()); }
/** * Get the {@link NodeDefinition} for the root node. * * @return the definition; never null * @throws RepositoryException * @throws NoSuchNodeTypeException */ JcrNodeDefinition getRootNodeDefinition() throws NoSuchNodeTypeException, RepositoryException { NodeTypes nodeTypes = nodeTypes(); for (NodeDefinition definition : nodeTypes.getNodeType(ModeShapeLexicon.ROOT).getChildNodeDefinitions()) { if (definition.getName().equals(JcrNodeType.RESIDUAL_ITEM_NAME)) return (JcrNodeDefinition)definition; } assert false; // should not get here return null; }
/** * Get the {@link NodeDefinition} for the root node. * * @return the definition; never null * @throws RepositoryException * @throws NoSuchNodeTypeException */ JcrNodeDefinition getRootNodeDefinition() throws NoSuchNodeTypeException, RepositoryException { NodeTypes nodeTypes = nodeTypes(); for (NodeDefinition definition : nodeTypes.getNodeType(ModeShapeLexicon.ROOT).getChildNodeDefinitions()) { if (definition.getName().equals(JcrNodeType.RESIDUAL_ITEM_NAME)) return (JcrNodeDefinition)definition; } assert false; // should not get here return null; }
@Override public boolean canAddChildNode(String childNodeName) { // FIXME: properly calculate matching definition for (NodeDefinition definition : getChildNodeDefinitions()) { String name = definition.getName(); if (matches(childNodeName, name) || RESIDUAL_NAME.equals(name)) { return !definition.isProtected() && definition.getDefaultPrimaryType() != null; } } return false; }
@Override public boolean canAddChildNode(String childNodeName) { // FIXME: properly calculate matching definition for (NodeDefinition definition : getChildNodeDefinitions()) { String name = definition.getName(); if (matches(childNodeName, name) || RESIDUAL_NAME.equals(name)) { return !definition.isProtected() && definition.getDefaultPrimaryType() != null; } } return false; }
@Override public boolean canAddChildNode(String childNodeName) { // FIXME: properly calculate matching definition for (NodeDefinition definition : getChildNodeDefinitions()) { String name = definition.getName(); if (matches(childNodeName, name) || RESIDUAL_NAME.equals(name)) { return !definition.isProtected() && definition.getDefaultPrimaryType() != null; } } return false; }
protected NodeDefinition childDefn( NodeTypeDefinition nodeType, String name ) { for (NodeDefinition defn : nodeType.getDeclaredChildNodeDefinitions()) { if (defn.getName().equals(name)) return defn; } assertThat("Failed to find child node definition \"" + name + "\"", false, is(true)); return null; }
private void checkIfMetaDataIsDefineAsChildNode(NodeType nodeType) { List<NodeDefinition> childNode = Arrays.asList(nodeType.getDeclaredChildNodeDefinitions()); for (NodeDefinition nodeDefinition : childNode) { assertFalse("MetaData".equals(nodeDefinition.getName())); if (StringUtils.isNotBlank(nodeDefinition.getDefaultPrimaryTypeName())) { assertFalse(NodeTypes.MetaData.NAME.equals(nodeDefinition.getDefaultPrimaryTypeName())); } } }
private static void assertAutoCreatedItems(@NotNull Tree authorizableTree, @NotNull String ntName, @NotNull Root root) throws Exception { NodeType repUser = ReadOnlyNodeTypeManager.getInstance(root, NamePathMapper.DEFAULT).getNodeType(ntName); for (NodeDefinition cnd : repUser.getChildNodeDefinitions()) { if (cnd.isAutoCreated()) { assertTrue(authorizableTree.hasChild(cnd.getName())); } } for (PropertyDefinition pd : repUser.getPropertyDefinitions()) { if (pd.isAutoCreated()) { assertTrue(authorizableTree.hasProperty(pd.getName())); } } } }
public static void checkNodeType(String nodeTypeName, List<String> superTypes, NodeTypeManager nodeTypeManager) throws NoSuchNodeTypeException, RepositoryException { NodeType nodeTypeContent = nodeTypeManager.getNodeType(nodeTypeName); assertNotNull(nodeTypeContent); assertEquals("Should have only one generic child", 1, nodeTypeContent.getDeclaredChildNodeDefinitions().length); assertEquals("*", nodeTypeContent.getDeclaredChildNodeDefinitions()[0].getName()); assertEquals(false, nodeTypeContent.getDeclaredChildNodeDefinitions()[0].allowsSameNameSiblings()); assertEquals("Should have " + superTypes.size() + " supertype defined", superTypes.size(), nodeTypeContent.getDeclaredSupertypeNames().length); assertEquals("Should have 2 propertyDefinition defined", 2, nodeTypeContent.getDeclaredPropertyDefinitions().length); assertTrue("Should have all supertype declared", containsAllSupertypes(nodeTypeContent, superTypes)); }