/** * Determine if either the primary type or any of the mixin types allows SNS. * * @param primaryType the primary type name; may not be null * @param mixinTypes the mixin type names; may be null or empty * @return {@code true} if either the primary type or any of the mixin types allows SNS. If neither allow SNS, * this will return {@code false} */ public boolean allowsNameSiblings( Name primaryType, Set<Name> mixinTypes ) { if (isUnorderedCollection(primaryType, mixinTypes)) { // regardless of the actual types, if at least one of them is an unordered collection, SNS are not allowed return false; } if (nodeTypeNamesThatAllowSameNameSiblings.contains(primaryType)) return true; if (mixinTypes != null && !mixinTypes.isEmpty()) { for (Name mixinType : mixinTypes) { if (nodeTypeNamesThatAllowSameNameSiblings.contains(mixinType)) return true; } } return false; }
/** * Determine if either the primary type or any of the mixin types allows SNS. * * @param primaryType the primary type name; may not be null * @param mixinTypes the mixin type names; may be null or empty * @return {@code true} if either the primary type or any of the mixin types allows SNS. If neither allow SNS, * this will return {@code false} */ public boolean allowsNameSiblings( Name primaryType, Set<Name> mixinTypes ) { if (isUnorderedCollection(primaryType, mixinTypes)) { // regardless of the actual types, if at least one of them is an unordered collection, SNS are not allowed return false; } if (nodeTypeNamesThatAllowSameNameSiblings.contains(primaryType)) return true; if (mixinTypes != null && !mixinTypes.isEmpty()) { for (Name mixinType : mixinTypes) { if (nodeTypeNamesThatAllowSameNameSiblings.contains(mixinType)) return true; } } return false; }
@Override public void createProjection( String absNodePath, String sourceName, String externalPath, String alias ) throws RepositoryException { AbstractJcrNode node = session.getNode(absNodePath); if (session.nodeTypeManager().nodeTypes().isUnorderedCollection(node.getPrimaryTypeName(), node.getMixinTypeNames())) { throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("create projection")); } NodeKey parentNodeToBecomeFederatedKey = node.key(); String projectionAlias = !StringUtil.isBlank(alias) ? alias : externalPath; if (projectionAlias.endsWith("/")) { projectionAlias = projectionAlias.substring(0, projectionAlias.length() - 1); } if (projectionAlias.contains("/")) { projectionAlias = projectionAlias.substring(projectionAlias.lastIndexOf("/") + 1); } if (StringUtil.isBlank(projectionAlias)) { // we cannot create an external projection without a valid alias return; } SessionCache sessionCache = this.session.spawnSessionCache(false); SessionCache systemSession = session.repository.createSystemSession(session.context(), false); String externalNodeKey = documentStore.createExternalProjection(parentNodeToBecomeFederatedKey.toString(), sourceName, externalPath, projectionAlias, systemSession); MutableCachedNode mutable = sessionCache.mutable(parentNodeToBecomeFederatedKey); mutable.addFederatedSegment(externalNodeKey, projectionAlias); systemSession.save(sessionCache, null); }
@Override public void createProjection( String absNodePath, String sourceName, String externalPath, String alias ) throws RepositoryException { AbstractJcrNode node = session.getNode(absNodePath); if (session.nodeTypeManager().nodeTypes().isUnorderedCollection(node.getPrimaryTypeName(), node.getMixinTypeNames())) { throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("create projection")); } NodeKey parentNodeToBecomeFederatedKey = node.key(); String projectionAlias = !StringUtil.isBlank(alias) ? alias : externalPath; if (projectionAlias.endsWith("/")) { projectionAlias = projectionAlias.substring(0, projectionAlias.length() - 1); } if (projectionAlias.contains("/")) { projectionAlias = projectionAlias.substring(projectionAlias.lastIndexOf("/") + 1); } if (StringUtil.isBlank(projectionAlias)) { // we cannot create an external projection without a valid alias return; } SessionCache sessionCache = this.session.spawnSessionCache(false); SessionCache systemSession = session.repository.createSystemSession(session.context(), false); String externalNodeKey = documentStore.createExternalProjection(parentNodeToBecomeFederatedKey.toString(), sourceName, externalPath, projectionAlias, systemSession); MutableCachedNode mutable = sessionCache.mutable(parentNodeToBecomeFederatedKey); mutable.addFederatedSegment(externalNodeKey, projectionAlias); systemSession.save(sessionCache, null); }
if (isUnorderedCollection(internalName, supertypeNames)) { boolean isVersionable = isVersionable(internalName, supertypeNames); if (isVersionable || foundSNS || nodeType.hasOrderableChildNodes()) {
if (isUnorderedCollection(internalName, supertypeNames)) { boolean isVersionable = isVersionable(internalName, supertypeNames); if (isVersionable || foundSNS || nodeType.hasOrderableChildNodes()) {
if (nodeTypes.isUnorderedCollection(removedMixinName, null)) { if (hasNodes()) {
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); } }
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); } }
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) {
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) {
if (nodeTypes.isUnorderedCollection(mixinTypeName, null)) {
if (nodeTypes.isUnorderedCollection(mixinTypeName, null)) {
if (nodeTypes.isUnorderedCollection(sourceNode.getPrimaryTypeName(), sourceNode.getMixinTypeNames())) { throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("copy"));
if (nodeTypes.isUnorderedCollection(sourceNode.getPrimaryTypeName(), sourceNode.getMixinTypeNames())) { throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("copy"));
if (nodeTypes.isUnorderedCollection(sourceNode.getPrimaryTypeName(), sourceNode.getMixinTypeNames())) { throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("clone"));
MutableCachedNode mutableDestParent = destParentNode.mutable(); if (mutableSrcParent.equals(mutableDestParent)) { if (nodeTypeManager().nodeTypes().isUnorderedCollection(srcParent.getPrimaryTypeName(), srcParent.getMixinTypeNames())) { throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("rename"));
MutableCachedNode mutableDestParent = destParentNode.mutable(); if (mutableSrcParent.equals(mutableDestParent)) { if (nodeTypeManager().nodeTypes().isUnorderedCollection(srcParent.getPrimaryTypeName(), srcParent.getMixinTypeNames())) { throw new ConstraintViolationException(JcrI18n.operationNotSupportedForUnorderedCollections.text("rename"));
if (nodeTypes.isUnorderedCollection(childPrimaryNodeTypeName, null)) {
if (nodeTypes.isUnorderedCollection(childPrimaryNodeTypeName, null)) {