private void assertNodeType( String nodeType, AbstractJcrNode node ) throws ItemNotFoundException, InvalidItemStateException { if (!StringUtil.isBlank(nodeType)) { assertEquals("Invalid node type " + nodeType, nodeType, node.getPrimaryTypeName().getString()); } }
@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); }
/** * Get the property definition ID. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final PropertyDefinitionId propertyDefinitionId() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); PropertyDefinitionId id = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes).getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return id; } return defn.propDefnId; }
/** * Get the property definition ID. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final PropertyDefinitionId propertyDefinitionId() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); PropertyDefinitionId id = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes).getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return id; } return defn.propDefnId; }
/** * Get the definition for this property. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final JcrPropertyDefinition propertyDefinition() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); JcrPropertyDefinition propDefn = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes); PropertyDefinitionId id = propDefn.getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return propDefn; } return nodeTypes.getPropertyDefinition(defn.propDefnId); }
/** * Get the definition for this property. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final JcrPropertyDefinition propertyDefinition() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); JcrPropertyDefinition propDefn = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes); PropertyDefinitionId id = propDefn.getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return propDefn; } return nodeTypes.getPropertyDefinition(defn.propDefnId); }
Name primaryTypeName = node.getPrimaryTypeName(); Set<Name> mixinTypeNames = node.getMixinTypeNames(); props.add(factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FROZEN_NODE));
private void fireSequencingFailureEvent( AbstractJcrNode sequencedNode, JcrSession inputSession, Throwable cause, String sequencerName ) throws RepositoryException { assert sequencedNode != null; assert inputSession != null; Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); final ExecutionContext context = inputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(inputSession.sessionId(), context.getProcessId(), inputSession.getRepository().repositoryKey(), inputSession.workspaceName(), inputSession.getRepository() .journalId()); sequencingChanges.nodeSequencingFailure(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName, cause); repository.changeBus().notify(sequencingChanges); }
private void fireSequencingFailureEvent( AbstractJcrNode sequencedNode, JcrSession inputSession, Throwable cause, String sequencerName ) throws RepositoryException { assert sequencedNode != null; assert inputSession != null; Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); final ExecutionContext context = inputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(inputSession.sessionId(), context.getProcessId(), inputSession.getRepository().repositoryKey(), inputSession.workspaceName(), inputSession.getRepository() .journalId()); sequencingChanges.nodeSequencingFailure(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName, cause); repository.changeBus().notify(sequencingChanges); }
parentNode = session.node(parentPath); parentPrimaryType = parentNode.getPrimaryTypeName(); parentMixinTypes = parentNode.getMixinTypeNames(); } catch (RepositoryException e) {
parentNode = session.node(parentPath); parentPrimaryType = parentNode.getPrimaryTypeName(); parentMixinTypes = parentNode.getMixinTypeNames(); } catch (RepositoryException e) {
private void fireSequencingEvent( AbstractJcrNode sequencedNode, List<AbstractJcrNode> outputNodes, JcrSession outputSession, String sequencerName ) throws RepositoryException { final ExecutionContext context = outputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(outputSession.sessionId(), context.getProcessId(), outputSession.getRepository().repositoryKey(), outputSession.workspaceName(), outputSession.getRepository() .journalId()); Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); for (AbstractJcrNode outputNode : outputNodes) { sequencingChanges.nodeSequenced(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, outputNode.key(), outputNode.path(), work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName); } sequencingChanges.freeze(outputSession.getUserID(), null, context.getValueFactories().getDateFactory().create()); repository.changeBus().notify(sequencingChanges); }
private void fireSequencingEvent( AbstractJcrNode sequencedNode, List<AbstractJcrNode> outputNodes, JcrSession outputSession, String sequencerName ) throws RepositoryException { final ExecutionContext context = outputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(outputSession.sessionId(), context.getProcessId(), outputSession.getRepository().repositoryKey(), outputSession.workspaceName(), outputSession.getRepository() .journalId()); Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); for (AbstractJcrNode outputNode : outputNodes) { sequencingChanges.nodeSequenced(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, outputNode.key(), outputNode.path(), work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName); } sequencingChanges.freeze(outputSession.getUserID(), null, context.getValueFactories().getDateFactory().create()); repository.changeBus().notify(sequencingChanges); }
boolean isNodeUnorderedCollection = nodeTypes.isUnorderedCollection(getPrimaryTypeName(), getMixinTypeNames()); if ((isExternal() || isNodeUnorderedCollection) && session().nodeTypes().isVersionable(mixinNameObj)) { return false;
boolean isNodeUnorderedCollection = nodeTypes.isUnorderedCollection(getPrimaryTypeName(), getMixinTypeNames()); if ((isExternal() || isNodeUnorderedCollection) && session().nodeTypes().isVersionable(mixinNameObj)) { return false;
void addSharedNode( AbstractJcrNode shareableNode, Name newNodeName ) throws RepositoryException { assert session == shareableNode.session; session.checkPermission(this, ModeShapePermissions.ADD_NODE); if (isLockedByAnotherSession()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(location())); } // Determine the node type based upon this node's type information ... SessionCache cache = sessionCache(); MutableCachedNode node = mutable(); // validate there is an appropriate child node definition JcrNodeDefinition childDefn = validateChildNodeDefinition(newNodeName, shareableNode.getPrimaryTypeName(), true); // See if this node is checked in. If so, then we can only create children if the child // node definition has an OPV of 'ignore'. See Section 15.2.2 of the JSR-283 spec for details ... if (!isCheckedOut() && childDefn.getOnParentVersion() != OnParentVersionAction.IGNORE) { // The OPV is not 'ignore', so we can't create the new node ... Path parentPath = path(); String parentPathStr = readable(parentPath); int numExistingSns = node.getChildReferences(cache).getChildCount(newNodeName); int sns = numExistingSns + 1; String segment = readable(session.pathFactory().createSegment(newNodeName, sns)); String opv = OnParentVersionAction.nameFromValue(childDefn.getOnParentVersion()); I18n msg = JcrI18n.cannotCreateChildOnCheckedInNodeSinceOpvOfChildDefinitionIsNotIgnore; throw new VersionException(msg.text(segment, readable(parentPathStr), childDefn.getName(), opv)); } // We can create the shared node ... NodeKey childKey = shareableNode.key(); node.linkChild(cache, childKey, newNodeName); }
void addSharedNode( AbstractJcrNode shareableNode, Name newNodeName ) throws RepositoryException { assert session == shareableNode.session; session.checkPermission(this, ModeShapePermissions.ADD_NODE); if (isLockedByAnotherSession()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(location())); } // Determine the node type based upon this node's type information ... SessionCache cache = sessionCache(); MutableCachedNode node = mutable(); // validate there is an appropriate child node definition JcrNodeDefinition childDefn = validateChildNodeDefinition(newNodeName, shareableNode.getPrimaryTypeName(), true); // See if this node is checked in. If so, then we can only create children if the child // node definition has an OPV of 'ignore'. See Section 15.2.2 of the JSR-283 spec for details ... if (!isCheckedOut() && childDefn.getOnParentVersion() != OnParentVersionAction.IGNORE) { // The OPV is not 'ignore', so we can't create the new node ... Path parentPath = path(); String parentPathStr = readable(parentPath); int numExistingSns = node.getChildReferences(cache).getChildCount(newNodeName); int sns = numExistingSns + 1; String segment = readable(session.pathFactory().createSegment(newNodeName, sns)); String opv = OnParentVersionAction.nameFromValue(childDefn.getOnParentVersion()); I18n msg = JcrI18n.cannotCreateChildOnCheckedInNodeSinceOpvOfChildDefinitionIsNotIgnore; throw new VersionException(msg.text(segment, readable(parentPathStr), childDefn.getName(), opv)); } // We can create the shared node ... NodeKey childKey = shareableNode.key(); node.linkChild(cache, childKey, newNodeName); }
if (newPrimaryTypeName.equals(getPrimaryTypeName())) return;
if (newPrimaryTypeName.equals(getPrimaryTypeName())) return;