public boolean isMixin() { return ntd.isMixin(); }
public NodeType[] getSupertypes() { Set<NodeType> nodeTypeList = new HashSet<NodeType>(); try { for (String ntName : ntd.getDeclaredSupertypeNames()) { nodeTypeList.add(nodeTypeManager.getNodeType(ntName)); } // if no super types, at least return nt:base if (nodeTypeList.size() == 0 && (!ntd.isMixin()) && !ntd.getName().equals("nt:base")) { nodeTypeList.add(nodeTypeManager.getNodeType("nt:base")); } } catch (RepositoryException e) { log.error("Registry Error while getting super types " + e.getMessage()); } return nodeTypeList.toArray(new NodeType[0]); }
private static void ensureNtBase(NodeTypeTemplate ntt, Map<String, NodeTypeTemplate> templates, NodeTypeManager nodeTypeManager) throws RepositoryException { if (!ntt.isMixin() && !NT_BASE.equals(ntt.getName())) { String[] supertypes = ntt.getDeclaredSupertypeNames(); if (supertypes.length == 0) { ntt.setDeclaredSuperTypeNames(new String[] {NT_BASE}); } else { // Check whether we need to add the implicit "nt:base" supertype boolean needsNtBase = true; for (String name : supertypes) { NodeTypeDefinition std = templates.get(name); if (std == null) { std = nodeTypeManager.getNodeType(name); } if (std != null && !std.isMixin()) { needsNtBase = false; } } if (needsNtBase) { String[] withNtBase = new String[supertypes.length + 1]; withNtBase[0] = NT_BASE; System.arraycopy(supertypes, 0, withNtBase, 1, supertypes.length); ntt.setDeclaredSuperTypeNames(withNtBase); } } } }
private static void ensureNtBase(NodeTypeTemplate ntt, Map<String, NodeTypeTemplate> templates, NodeTypeManager nodeTypeManager) throws RepositoryException { if (!ntt.isMixin() && !NT_BASE.equals(ntt.getName())) { String[] supertypes = ntt.getDeclaredSupertypeNames(); if (supertypes.length == 0) { ntt.setDeclaredSuperTypeNames(new String[] {NT_BASE}); } else { // Check whether we need to add the implicit "nt:base" supertype boolean needsNtBase = true; for (String name : supertypes) { NodeTypeDefinition std = templates.get(name); if (std == null) { std = nodeTypeManager.getNodeType(name); } if (std != null && !std.isMixin()) { needsNtBase = false; } } if (needsNtBase) { String[] withNtBase = new String[supertypes.length + 1]; withNtBase[0] = NT_BASE; System.arraycopy(supertypes, 0, withNtBase, 1, supertypes.length); ntt.setDeclaredSuperTypeNames(withNtBase); } } } }
private static void ensureNtBase(NodeTypeTemplate ntt, Map<String, NodeTypeTemplate> templates, NodeTypeManager nodeTypeManager) throws RepositoryException { if (!ntt.isMixin() && !NT_BASE.equals(ntt.getName())) { String[] supertypes = ntt.getDeclaredSupertypeNames(); if (supertypes.length == 0) { ntt.setDeclaredSuperTypeNames(new String[] {NT_BASE}); } else { // Check whether we need to add the implicit "nt:base" supertype boolean needsNtBase = true; for (String name : supertypes) { NodeTypeDefinition std = templates.get(name); if (std == null) { std = nodeTypeManager.getNodeType(name); } if (std != null && !std.isMixin()) { needsNtBase = false; } } if (needsNtBase) { String[] withNtBase = new String[supertypes.length + 1]; withNtBase[0] = NT_BASE; System.arraycopy(supertypes, 0, withNtBase, 1, supertypes.length); ntt.setDeclaredSuperTypeNames(withNtBase); } } } }
public void testEmptyNodeTypeTemplate() throws Exception { NodeTypeTemplate ntt = ntm.createNodeTypeTemplate(); assertNull(ntt.getName()); assertFalse(ntt.isMixin()); assertFalse(ntt.isAbstract()); assertFalse(ntt.hasOrderableChildNodes()); // note: isQueryable cannot be tested as defautl value is defined // by the implementation assertNotNull(ntt.getDeclaredSupertypeNames()); assertEquals(0, ntt.getDeclaredSupertypeNames().length); assertNull(ntt.getPrimaryItemName()); assertNull(ntt.getDeclaredChildNodeDefinitions()); assertNull(ntt.getDeclaredPropertyDefinitions()); assertNotNull(ntt.getNodeDefinitionTemplates()); assertTrue(ntt.getNodeDefinitionTemplates().isEmpty()); assertNotNull(ntt.getPropertyDefinitionTemplates()); assertTrue(ntt.getPropertyDefinitionTemplates().isEmpty()); }
@Test public void testCreateSimpleMixinNodeTypeLastModified() throws RepositoryException { // GIVEN String name = NodeTypes.Content.NAME; List<String> superTypes = new ArrayList<String>(); superTypes.add(NodeTypes.Created.NAME); superTypes.add(NodeTypes.Activatable.NAME); superTypes.add(NodeTypes.LastModified.NAME); superTypes.add(NodeTypes.Renderable.NAME); superTypes.add(NodeTypes.Versionable.NAME); // WHEN NodeTypeTemplate nodeTypeTemplate = NodeTypeTemplateUtil.createSimpleNodeType(nodeTypeManager, name, superTypes); // THEN assertNotNull(nodeTypeTemplate); assertEquals(NodeTypes.Content.NAME, nodeTypeTemplate.getName()); assertFalse(nodeTypeTemplate.isMixin()); assertEquals(5, nodeTypeTemplate.getDeclaredSupertypeNames().length); assertEquals(2, nodeTypeTemplate.getPropertyDefinitionTemplates().size()); assertEquals(1, nodeTypeTemplate.getDeclaredChildNodeDefinitions().length); NodeDefinition child = nodeTypeTemplate.getDeclaredChildNodeDefinitions()[0]; assertEquals("*", child.getName()); assertFalse(child.isAutoCreated()); assertFalse(child.isMandatory()); assertFalse(child.allowsSameNameSiblings()); assertEquals(OnParentVersionAction.COPY, child.getOnParentVersion()); }
assertTrue(ntt.isMixin());
@Test public void testCreateSimpleNodeTypeContent() throws RepositoryException { // GIVEN String name = NodeTypes.LastModified.NAME; String superType = NodeType.NT_BASE; HashMap<String, Integer> propertyNameTypeMap = new HashMap<String, Integer>(); propertyNameTypeMap.put(NodeTypes.LastModified.LAST_MODIFIED, PropertyType.DATE); propertyNameTypeMap.put(NodeTypes.LastModified.LAST_MODIFIED_BY, PropertyType.STRING); // WHEN NodeTypeTemplate nodeTypeTemplate = NodeTypeTemplateUtil.createSimpleMixinNodeType(nodeTypeManager, name, superType, propertyNameTypeMap); // THEN assertNotNull(nodeTypeTemplate); assertEquals(NodeTypes.LastModified.LAST_MODIFIED, nodeTypeTemplate.getName()); assertTrue(nodeTypeTemplate.isMixin()); assertEquals(1, nodeTypeTemplate.getDeclaredSupertypeNames().length); assertEquals("nt:base", nodeTypeTemplate.getDeclaredSupertypeNames()[0]); assertEquals(2, nodeTypeTemplate.getPropertyDefinitionTemplates().size()); PropertyDefinitionTemplate lastModifiedProperty = (PropertyDefinitionTemplate) nodeTypeTemplate.getPropertyDefinitionTemplates().get(0); assertEquals(NodeTypes.LastModified.LAST_MODIFIED_BY, lastModifiedProperty.getName()); assertEquals(PropertyType.STRING, lastModifiedProperty.getRequiredType()); assertEquals(OnParentVersionAction.COPY, lastModifiedProperty.getOnParentVersion()); assertFalse(lastModifiedProperty.isAutoCreated()); assertFalse(lastModifiedProperty.isMandatory()); assertFalse(lastModifiedProperty.isProtected()); assertFalse(lastModifiedProperty.isMultiple()); PropertyDefinitionTemplate lastModifiedByProperty = (PropertyDefinitionTemplate) nodeTypeTemplate.getPropertyDefinitionTemplates().get(1); assertEquals(NodeTypes.LastModified.LAST_MODIFIED, lastModifiedByProperty.getName()); assertEquals(PropertyType.DATE, lastModifiedByProperty.getRequiredType()); }
assertEquals(ntt.isMixin(), ntd.isMixin()); assertEquals(ntt.isAbstract(), ntd.isAbstract()); assertEquals(ntt.hasOrderableChildNodes(), ntd.hasOrderableChildNodes());