protected JcrNodeType getNodeType( Name nodeTypeName ) { return nodeTypes.getNodeType(nodeTypeName); }
protected MultipleNodeDefinitionSet( Name primaryType, Set<Name> mixinTypes ) { super(primaryType, mixinTypes); this.nodeType = getNodeType(primaryType); if (mixinTypes == null || mixinTypes.isEmpty()) { this.additionalTypes = null; } else { this.additionalTypes = new JcrNodeType[mixinTypes.size()]; int index = -1; for (Name mixinType : mixinTypes) { this.additionalTypes[++index] = getNodeType(mixinType); } } }
protected MultipleNodeDefinitionSet( Name primaryType, Set<Name> mixinTypes ) { super(primaryType, mixinTypes); this.nodeType = getNodeType(primaryType); if (mixinTypes == null || mixinTypes.isEmpty()) { this.additionalTypes = null; } else { this.additionalTypes = new JcrNodeType[mixinTypes.size()]; int index = -1; for (Name mixinType : mixinTypes) { this.additionalTypes[++index] = getNodeType(mixinType); } } }
@Override public JcrNodeType getDefaultPrimaryType() { // It is valid for this field to be null. if (defaultPrimaryTypeName == null) { return null; } return nodeTypeManager.getNodeTypes().getNodeType(defaultPrimaryTypeName); }
@Override public JcrNodeType getDefaultPrimaryType() { // It is valid for this field to be null. if (defaultPrimaryTypeName == null) { return null; } return nodeTypeManager.getNodeTypes().getNodeType(defaultPrimaryTypeName); }
public Set<Name> getAllSubtypes( Name nodeTypeName ) { Set<Name> subtypes = new HashSet<>(); JcrNodeType type = getNodeType(nodeTypeName); if (type != null) { subtypes.add(nodeTypeName); for (JcrNodeType subtype : subtypesFor(type)) { subtypes.add(subtype.getInternalName()); } } return Collections.unmodifiableSet(subtypes); }
public Set<Name> getAllSubtypes( Name nodeTypeName ) { Set<Name> subtypes = new HashSet<>(); JcrNodeType type = getNodeType(nodeTypeName); if (type != null) { subtypes.add(nodeTypeName); for (JcrNodeType subtype : subtypesFor(type)) { subtypes.add(subtype.getInternalName()); } } return Collections.unmodifiableSet(subtypes); }
private Set<NodeType> nodeTypes( Set<Name> names ) { NodeTypes nodeTypes = session.repository().nodeTypeManager().getNodeTypes(); Set<NodeType> result = new HashSet<>(names.size()); for (Name name : names) { result.add(nodeTypes.getNodeType(name)); } return result; }
private Set<NodeType> nodeTypes( Set<Name> names ) { NodeTypes nodeTypes = session.repository().nodeTypeManager().getNodeTypes(); Set<NodeType> result = new HashSet<>(names.size()); for (Name name : names) { result.add(nodeTypes.getNodeType(name)); } return result; }
/** * 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; }
private NodeType nodeType( Name name ) { return session.repository().nodeTypeManager().getNodeTypes().getNodeType(name); }
/** * Returns the node type with the given name (if one exists) * * @param nodeTypeName the name of the node type to be returned * @return the node type with the given name (if one exists) * @see NodeTypes#getNodeType(Name) */ JcrNodeType getNodeType( Name nodeTypeName ) { JcrNodeType nodeType = nodeTypes().getNodeType(nodeTypeName); if (nodeType != null) { nodeType = nodeType.with(context(), session); } return nodeType; }
private NodeType nodeType( Name name ) { return session.repository().nodeTypeManager().getNodeTypes().getNodeType(name); }
@Test public void shouldReadNodeTypeDefinitionsFromSystemCatalog() { NodeTypes nodeTypes = repository.nodeTypeManager().getNodeTypes(); Set<Name> builtInNodeTypes = new HashSet<Name>(nodeTypes.getAllNodeTypeNames()); for (NodeTypeDefinition type : system.readAllNodeTypes()) { Name name = name(type.getName()); JcrNodeType actual = nodeTypes.getNodeType(name); assertThat("Did not find actual node type for name \"" + type.getName() + "\"", actual, is(notNullValue())); assertThat(builtInNodeTypes.remove(name), is(true)); } assertThat(builtInNodeTypes.isEmpty(), is(true)); }
@Override public JcrNodeType getNodeType( String nodeTypeName ) throws NoSuchNodeTypeException, RepositoryException { session.checkLive(); Name ntName = context().getValueFactories().getNameFactory().create(nodeTypeName); JcrNodeType type = nodeTypes().getNodeType(ntName); if (type != null) { type = type.with(context(), session); return type; } throw new NoSuchNodeTypeException(JcrI18n.typeNotFound.text(nodeTypeName)); }
@Override public JcrNodeType getNodeType( String nodeTypeName ) throws NoSuchNodeTypeException, RepositoryException { session.checkLive(); Name ntName = context().getValueFactories().getNameFactory().create(nodeTypeName); JcrNodeType type = nodeTypes().getNodeType(ntName); if (type != null) { type = type.with(context(), session); return type; } throw new NoSuchNodeTypeException(JcrI18n.typeNotFound.text(nodeTypeName)); }
private void compareTemplateToNodeType( JcrNodeTypeTemplate template, JcrNodeType nodeType ) { Name nodeTypeName = nameFactory.create(template.getName()); if (nodeType == null) { nodeType = nodeTypes().getNodeType(nodeTypeName); assertThat(nodeType.nodeTypeManager(), is(notNullValue())); } NodeTypeAssertion.compareTemplateToNodeType(template, nodeType); } }
@Test public void shouldAllowNewDefinitionWithNoChildNodesOrProperties() throws Exception { Name testTypeName = nameFactory.create(TEST_TYPE_NAME); ntTemplate.setName(TEST_TYPE_NAME); ntTemplate.setDeclaredSuperTypeNames(new String[] {"nt:base"}); JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate); assertThat(testNodeType.getName(), is(TEST_TYPE_NAME)); JcrNodeType nodeTypeFromRepo = nodeTypes().getNodeType(testTypeName); assertThat(nodeTypeFromRepo, is(notNullValue())); assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME)); }
@Test public void shouldAllowDefinitionWithExistingSupertypes() throws Exception { Name testTypeName = nameFactory.create(TEST_TYPE_NAME); ntTemplate.setName(TEST_TYPE_NAME); ntTemplate.setDeclaredSuperTypeNames(new String[] {"nt:base", "mix:referenceable"}); JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate); assertThat(testNodeType.getName(), is(TEST_TYPE_NAME)); JcrNodeType nodeTypeFromRepo = nodeTypes().getNodeType(testTypeName); assertThat(nodeTypeFromRepo, is(notNullValue())); assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME)); }
@Test( expected = NodeTypeExistsException.class ) public void shouldNotAllowRedefinitionOfNewTypeIfAllowUpdatesIsFalse() throws Exception { Name testTypeName = nameFactory.create(TEST_TYPE_NAME); ntTemplate.setName(TEST_TYPE_NAME); ntTemplate.setDeclaredSuperTypeNames(new String[] {"nt:base"}); JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate); assertThat(testNodeType.getName(), is(TEST_TYPE_NAME)); JcrNodeType nodeTypeFromRepo = nodeTypes().getNodeType(testTypeName); assertThat(nodeTypeFromRepo, is(notNullValue())); assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME)); testNodeType = repoTypeManager.registerNodeType(ntTemplate); }