Value[] values, boolean skipProtected ) { return findPropertyDefinition(session, primaryTypeName, mixinTypeNames, propertyName, values, skipProtected, true);
private void checkURINotInUse( String uri ) throws RepositoryException { NodeTypes nodeTypes = session.nodeTypes(); for (Name nodeTypeName : nodeTypes.getAllNodeTypeNames()) { if (nodeTypeName.getNamespaceUri().equals(uri)) { throw new NamespaceException(JcrI18n.unableToUnregisterPrefixForNamespaceUsedByNodeType.text(uri, nodeTypeName)); } } }
@Override public String toString() { return getAllNodeTypes().toString(); }
/** * Obtain a new version of this cache with the specified node types removed from the new cache. * * @param removedNodeTypes the node types that are to be removed from the resulting cache; may not be null but may be empty * @return the resulting cache that contains all of the node types within this cache but without the supplied node types; * never null */ protected NodeTypes without( Collection<JcrNodeType> removedNodeTypes ) { if (removedNodeTypes.isEmpty()) return this; Collection<JcrNodeType> nodeTypes = new HashSet<JcrNodeType>(this.nodeTypes.values()); nodeTypes.removeAll(removedNodeTypes); return new NodeTypes(this.context, nodeTypes, getVersion() + 1); }
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); }
RepositoryNodeTypeManager with( JcrRepository.RunningState repository, boolean includeColumnsForInheritedProperties, boolean includePseudoColumnsInSelectStar ) { assert this.systemWorkspaceName.equals(repository.repositoryCache().getSystemWorkspaceName()); PathFactory pathFactory = repository.context().getValueFactories().getPathFactory(); Path nodeTypesPath = pathFactory.createAbsolutePath(JcrLexicon.SYSTEM, JcrLexicon.NODE_TYPES); assert this.nodeTypesPath.equals(nodeTypesPath); RepositoryNodeTypeManager result = new RepositoryNodeTypeManager(repository, includeColumnsForInheritedProperties, includePseudoColumnsInSelectStar); // Now copy the node types from this cache into the new manager's cache ... // (If we didn't do this, we'd have to refresh from the system storage) result.nodeTypesCache = result.nodeTypesCache.with(this.nodeTypesCache.getAllNodeTypes()); // Do not copy the listeners return result; }
@Override public boolean canAddChildNode( String childNodeName, String primaryNodeTypeName ) { CheckArg.isNotNull(childNodeName, "childNodeName"); CheckArg.isNotNull(primaryNodeTypeName, "primaryNodeTypeName"); Name childName = context.getValueFactories().getNameFactory().create(childNodeName); Name childPrimaryTypeName = context.getValueFactories().getNameFactory().create(primaryNodeTypeName); NodeTypes nodeTypes = nodeTypes(); boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(this.name, null); JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, childPrimaryTypeName, skipProtected, SiblingCounter.constant(0)); if (childNodeDefinition == null) { // We found no valid child node definition ... return false; } if (RESIDUAL_ITEM_NAME.equals(childNodeDefinition.getName())) { // the TCK expects that for residual children definitions, this returns true return true; } if (childPrimaryTypeName != null) { // The child's primary node type name was given, so make sure that it is not abstract or a mixin. // If it were not for the residual item check (previous `if`), then we could do this at the top of the method. // But it has to go here. JcrNodeType childType = nodeTypes.getNodeType(childPrimaryTypeName); if (childType.isAbstract() || childType.isMixin()) return false; } return true; }
if (newPrimaryTypeName.equals(getPrimaryTypeName())) return; final JcrNodeType newPrimaryType = nodeTypes.getNodeType(newPrimaryTypeName); NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(primaryType, mixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, newPrimaryTypeName, skipProtected, siblingCounter); throw new ConstraintViolationException(msg.text(location(), oldPrimaryType, newPrimaryTypeName, ptype, mtypes)); setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion());
JcrNodeType foundNodeType = nodeTypes.getNodeType(nodeTypeName); if (foundNodeType == null) { throw new NoSuchNodeTypeException(JcrI18n.noSuchNodeType.text(name)); for (JcrNodeType nodeType : nodeTypes.getAllNodeTypes()) { NodeTypes newNodeTypes = nodeTypes.without(removedNodeTypes);
protected JcrNodeType getNodeType( Name nodeTypeName ) { return nodeTypes.getNodeType(nodeTypeName); }
CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session().nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { assert !this.isRoot(); NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected, siblingCounter); setNodeDefinitionId(id, nodeTypes.getVersion()); return childDefn; return nodeTypes.getChildNodeDefinition(defn.nodeDefnId);
boolean isNodeUnorderedCollection = nodeTypes.isUnorderedCollection(getPrimaryTypeName(), getMixinTypeNames()); if ((isExternal() || isNodeUnorderedCollection) && session().nodeTypes().isVersionable(mixinNameObj)) { return false; boolean isMixinUnorderedCollection = nodeTypes.isUnorderedCollection(mixinNameObj, null); if (isMixinUnorderedCollection) { if (isNodeUnorderedCollection) { Name childPrimaryType = child.getPrimaryType(cache); boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(mixinType.getInternalName(), null); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, childPrimaryType, skipProtected, siblingCounter);
final NodeKey nodeKey = modifiedNode.getKey(); if (nodeTypeCapabilities.isVersionable(primaryType, mixinTypes) && !systemContent.hasVersionHistory(nodeKey)) { if (modifiedNode.isNew() || nodeTypeCapabilities.allowsNameSiblings(primaryType, mixinTypes)) return; NodeDefinitionSet childDefns = nodeTypeCapabilities.findChildNodeDefinitions(primaryType, mixinTypes); JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, null, true, siblingCounter); childDefns = nodeTypeCapabilities.findChildNodeDefinitions(primaryType, mixinTypes); childNodeDefinition = childDefns.findBestDefinitionForChild(childName, childPrimaryType, true, siblingCounter);
@Test public void shouldAllowUnregisteringUnusedType() throws Exception { ntTemplate.setName(TEST_TYPE_NAME); JcrNodeDefinitionTemplate childNode = new JcrNodeDefinitionTemplate(this.context); childNode.setDefaultPrimaryTypeName(JcrNtLexicon.FILE.getString(this.registry)); ntTemplate.getNodeDefinitionTemplates().add(childNode); try { repoTypeManager.registerNodeType(ntTemplate); } catch (Exception ex) { fail(ex.getMessage()); } Name typeNameAsName = nameFactory.create(TEST_TYPE_NAME); int nodeTypeCount = nodeTypes().getAllNodeTypes().size(); repoTypeManager.unregisterNodeType(Arrays.asList(new Name[] {typeNameAsName}), true); assertThat(nodeTypes().getAllNodeTypes().size(), is(nodeTypeCount - 1)); assertThat(nodeTypes().getNodeType(typeNameAsName), is(nullValue())); }
@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)); }
public ChildReferences getChildReferences( WorkspaceCache cache, Document document ) { Name primaryType = getPrimaryType(document); Set<Name> mixinTypes = getMixinTypes(document); NodeTypes nodeTypes = getNodeTypes(cache); boolean isUnorderedCollection = nodeTypes != null && nodeTypes.isUnorderedCollection(primaryType, mixinTypes); if (isUnorderedCollection) { return new BucketedChildReferences(document, this); } boolean hasChildren = document.containsField(CHILDREN); boolean hasFederatedSegments = document.containsField(FEDERATED_SEGMENTS); if (!hasChildren && !hasFederatedSegments) { return ImmutableChildReferences.EMPTY_CHILD_REFERENCES; } boolean allowsSNS = nodeTypes == null || nodeTypes.allowsNameSiblings(primaryType, mixinTypes); ChildReferences internalChildRefs = hasChildren ? ImmutableChildReferences.create(this, document, CHILDREN, allowsSNS) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES; ChildReferences externalChildRefs = hasFederatedSegments ? ImmutableChildReferences.create(this, document, FEDERATED_SEGMENTS, allowsSNS) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES; // Now look at the 'childrenInfo' document for info about the next block of children ... ChildReferencesInfo info = getChildReferencesInfo(document); if (!hasChildren) { return ImmutableChildReferences.create(externalChildRefs, info, cache, allowsSNS); } else if (!hasFederatedSegments) { return ImmutableChildReferences.create(internalChildRefs, info, cache, allowsSNS); } else { return ImmutableChildReferences.create(internalChildRefs, info, externalChildRefs, cache, allowsSNS); } }
CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session().nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { assert !this.isRoot(); SiblingCounter siblingCounter = SiblingCounter.create(parent, cache); boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected, siblingCounter); setNodeDefinitionId(id, nodeTypes.getVersion()); return id;
boolean skipProtected ) { JcrNodeType primaryType = getNodeType(primaryTypeNameOfParent); if (primaryType != null) { for (JcrNodeDefinition definition : primaryType.allChildNodeDefinitions(childName)) { JcrNodeType mixinType = getNodeType(mixinTypeName); if (mixinType == null) continue; for (JcrNodeDefinition definition : mixinType.allChildNodeDefinitions(childName)) { if (!childName.equals(JcrNodeType.RESIDUAL_NAME)) return canRemoveAllChildren(primaryTypeNameOfParent, mixinTypeNamesOfParent, JcrNodeType.RESIDUAL_NAME, skipProtected);
boolean skipProtected ) { JcrNodeType primaryType = getNodeType(primaryTypeNameOfParent); if (primaryType != null) { for (JcrPropertyDefinition definition : primaryType.allPropertyDefinitions(propertyName)) { JcrNodeType mixinType = getNodeType(mixinTypeName); if (mixinType == null) continue; for (JcrPropertyDefinition definition : mixinType.allPropertyDefinitions(propertyName)) { if (!propertyName.equals(JcrNodeType.RESIDUAL_NAME)) return canRemoveProperty(primaryTypeNameOfParent, mixinTypeNamesOfParent, JcrNodeType.RESIDUAL_NAME, skipProtected);
boolean skipProtected ) { JcrNodeType primaryType = getNodeType(primaryTypeNameOfParent); if (primaryType != null) { for (JcrPropertyDefinition definition : primaryType.allPropertyDefinitions(itemName)) { JcrNodeType mixinType = getNodeType(mixinTypeName); if (mixinType == null) continue; for (JcrPropertyDefinition definition : mixinType.allPropertyDefinitions(itemName)) { JcrNodeType mixinType = getNodeType(mixinTypeName); if (mixinType == null) continue; for (JcrNodeDefinition definition : mixinType.allChildNodeDefinitions(itemName)) { if (!itemName.equals(JcrNodeType.RESIDUAL_NAME)) return canRemoveItem(primaryTypeNameOfParent, mixinTypeNamesOfParent, JcrNodeType.RESIDUAL_NAME, skipProtected); return false;