boolean isLockable() throws RepositoryException { return isNodeType(JcrMixLexicon.LOCKABLE); }
boolean isLockable() throws RepositoryException { return isNodeType(JcrMixLexicon.LOCKABLE); }
boolean isShareable() throws RepositoryException { return isNodeType(JcrMixLexicon.SHAREABLE); }
boolean isShareable() throws RepositoryException { return isNodeType(JcrMixLexicon.SHAREABLE); }
@Override public boolean isNodeType( String nodeTypeName ) throws RepositoryException { return isNodeType(nameFrom(nodeTypeName)); }
@Override public boolean isNodeType( String nodeTypeName ) throws RepositoryException { return isNodeType(nameFrom(nodeTypeName)); }
/** * Throw an {@link UnsupportedRepositoryOperationException} if the node is not versionable (i.e., * isNodeType(JcrMixLexicon.VERSIONABLE) == false). * * @param node the node to check * @throws UnsupportedRepositoryOperationException if <code>!isNodeType({@link JcrMixLexicon#VERSIONABLE})</code> * @throws RepositoryException if an error occurs reading the node types for this node */ private void checkVersionable( AbstractJcrNode node ) throws UnsupportedRepositoryOperationException, RepositoryException { if (!node.isNodeType(JcrMixLexicon.VERSIONABLE)) { throw new UnsupportedRepositoryOperationException(JcrI18n.requiresVersionable.text()); } }
/** * Throw an {@link UnsupportedRepositoryOperationException} if the node is not versionable (i.e., * isNodeType(JcrMixLexicon.VERSIONABLE) == false). * * @param node the node to check * @throws UnsupportedRepositoryOperationException if <code>!isNodeType({@link JcrMixLexicon#VERSIONABLE})</code> * @throws RepositoryException if an error occurs reading the node types for this node */ private void checkVersionable( AbstractJcrNode node ) throws UnsupportedRepositoryOperationException, RepositoryException { if (!node.isNodeType(JcrMixLexicon.VERSIONABLE)) { throw new UnsupportedRepositoryOperationException(JcrI18n.requiresVersionable.text()); } }
@Override public VersionIterator getAllLinearVersions() throws RepositoryException { AbstractJcrNode existingNode = session().getNonSystemNodeByIdentifier(getVersionableIdentifier()); if (existingNode == null) return getAllVersions(); assert existingNode.isNodeType(JcrMixLexicon.VERSIONABLE); LinkedList<JcrVersionNode> versions = new LinkedList<JcrVersionNode>(); JcrVersionNode baseVersion = existingNode.getBaseVersion(); while (baseVersion != null) { versions.addFirst(baseVersion); baseVersion = baseVersion.getLinearPredecessor(); } return new LinearVersionIterator(versions, versions.size()); }
@Override public VersionIterator getAllLinearVersions() throws RepositoryException { AbstractJcrNode existingNode = session().getNonSystemNodeByIdentifier(getVersionableIdentifier()); if (existingNode == null) return getAllVersions(); assert existingNode.isNodeType(JcrMixLexicon.VERSIONABLE); LinkedList<JcrVersionNode> versions = new LinkedList<JcrVersionNode>(); JcrVersionNode baseVersion = existingNode.getBaseVersion(); while (baseVersion != null) { versions.addFirst(baseVersion); baseVersion = baseVersion.getLinearPredecessor(); } return new LinearVersionIterator(versions, versions.size()); }
private void setCreatedByIfNecessary( JcrSession outputSession, List<AbstractJcrNode> outputNodes ) throws RepositoryException { // if the mix:created mixin is on any of the new nodes, we need to set the createdBy here, otherwise it will be // set by the system session when it saves and it will default to "modeshape-worker" for (AbstractJcrNode node : outputNodes) { if (node.isNodeType(JcrMixLexicon.CREATED)) { node.setProperty(JcrLexicon.CREATED_BY, outputSession.getValueFactory().createValue(work.getUserId()), true, true, false, false); } } }
private void setCreatedByIfNecessary( JcrSession outputSession, List<AbstractJcrNode> outputNodes ) throws RepositoryException { // if the mix:created mixin is on any of the new nodes, we need to set the createdBy here, otherwise it will be // set by the system session when it saves and it will default to "modeshape-worker" for (AbstractJcrNode node : outputNodes) { if (node.isNodeType(JcrMixLexicon.CREATED)) { node.setProperty(JcrLexicon.CREATED_BY, outputSession.getValueFactory().createValue(work.getUserId()), true, true, false, false); } } }
protected final Path correspondingNodePath( String workspaceName ) throws NoSuchWorkspaceException, ItemNotFoundException, RepositoryException { assert workspaceName != null; NamespaceRegistry namespaces = this.context().getNamespaceRegistry(); // Find the closest ancestor (including this node) that is referenceable ... AbstractJcrNode referenceableRoot = this; while (!referenceableRoot.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(namespaces))) { referenceableRoot = referenceableRoot.getParent(); } // Find the relative path from the nearest referenceable node to this node (or null if this node is referenceable) ... Path relativePath = path().equals(referenceableRoot.path()) ? null : path().relativeTo(referenceableRoot.path()); NodeKey key = referenceableRoot.key(); // if the we're looking for a system node, we need to use the system ws name, which is repository-wide String systemWsKey = session.getRepository().systemWorkspaceKey(); String workspaceKey = systemWsKey.equals(key.getWorkspaceKey()) ? systemWsKey : NodeKey.keyForWorkspaceName(workspaceName); NodeKey nodeKey = new NodeKey(key.getSourceKey(), workspaceKey, key.getIdentifier()); return session.getPathForCorrespondingNode(workspaceName, nodeKey, relativePath); }
protected final Path correspondingNodePath( String workspaceName ) throws NoSuchWorkspaceException, ItemNotFoundException, RepositoryException { assert workspaceName != null; NamespaceRegistry namespaces = this.context().getNamespaceRegistry(); // Find the closest ancestor (including this node) that is referenceable ... AbstractJcrNode referenceableRoot = this; while (!referenceableRoot.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(namespaces))) { referenceableRoot = referenceableRoot.getParent(); } // Find the relative path from the nearest referenceable node to this node (or null if this node is referenceable) ... Path relativePath = path().equals(referenceableRoot.path()) ? null : path().relativeTo(referenceableRoot.path()); NodeKey key = referenceableRoot.key(); // if the we're looking for a system node, we need to use the system ws name, which is repository-wide String systemWsKey = session.getRepository().systemWorkspaceKey(); String workspaceKey = systemWsKey.equals(key.getWorkspaceKey()) ? systemWsKey : NodeKey.keyForWorkspaceName(workspaceName); NodeKey nodeKey = new NodeKey(key.getSourceKey(), workspaceKey, key.getIdentifier()); return session.getPathForCorrespondingNode(workspaceName, nodeKey, relativePath); }
void cancelMerge( AbstractJcrNode targetNode, Version version ) throws RepositoryException { targetNode.session().checkLive(); checkVersionable(targetNode); if (targetNode.isNew() || targetNode.isModified()) { throw new InvalidItemStateException(JcrI18n.noPendingChangesAllowedForNode.text()); } if (!targetNode.isNodeType(JcrMixLexicon.VERSIONABLE)) { throw new UnsupportedRepositoryOperationException(JcrI18n.requiresVersionable.text()); } removeVersionFromMergeFailedProperty(targetNode, version); targetNode.session().save(); }
void cancelMerge( AbstractJcrNode targetNode, Version version ) throws RepositoryException { targetNode.session().checkLive(); checkVersionable(targetNode); if (targetNode.isNew() || targetNode.isModified()) { throw new InvalidItemStateException(JcrI18n.noPendingChangesAllowedForNode.text()); } if (!targetNode.isNodeType(JcrMixLexicon.VERSIONABLE)) { throw new UnsupportedRepositoryOperationException(JcrI18n.requiresVersionable.text()); } removeVersionFromMergeFailedProperty(targetNode, version); targetNode.session().save(); }
void doneMerge( AbstractJcrNode targetNode, Version version ) throws RepositoryException { targetNode.session().checkLive(); checkVersionable(targetNode); if (targetNode.isNew() || targetNode.isModified()) { throw new InvalidItemStateException(JcrI18n.noPendingChangesAllowedForNode.text()); } if (!targetNode.isNodeType(JcrMixLexicon.VERSIONABLE)) { throw new VersionException(JcrI18n.requiresVersionable.text()); } AbstractJcrProperty prop = targetNode.getProperty(JcrLexicon.PREDECESSORS); JcrValue[] values = prop.getValues(); JcrValue[] newValues = new JcrValue[values.length + 1]; System.arraycopy(values, 0, newValues, 0, values.length); newValues[values.length] = targetNode.valueFrom(version); targetNode.setProperty(JcrLexicon.PREDECESSORS, newValues, PropertyType.REFERENCE, false); removeVersionFromMergeFailedProperty(targetNode, version); targetNode.session().save(); }
@SuppressWarnings( "deprecation" ) protected String identifierPathFor( String pathToNode ) throws Exception { AbstractJcrNode node = session.getNode(pathToNode); if (node.isNodeType("mix:referenceable")) { // Make sure that the identifier matches the UUID ... assertThat(node.getUUID(), is(node.getIdentifier())); } else { try { node.getUUID(); fail("Should have thrown an UnsupportedRepositoryOperationException if the node " + pathToNode + " is not referenceable"); } catch (UnsupportedRepositoryOperationException e) { // expected } } return node.identifierPath(); } }
void doneMerge( AbstractJcrNode targetNode, Version version ) throws RepositoryException { targetNode.session().checkLive(); checkVersionable(targetNode); if (targetNode.isNew() || targetNode.isModified()) { throw new InvalidItemStateException(JcrI18n.noPendingChangesAllowedForNode.text()); } if (!targetNode.isNodeType(JcrMixLexicon.VERSIONABLE)) { throw new VersionException(JcrI18n.requiresVersionable.text()); } AbstractJcrProperty prop = targetNode.getProperty(JcrLexicon.PREDECESSORS); JcrValue[] values = prop.getValues(); JcrValue[] newValues = new JcrValue[values.length + 1]; System.arraycopy(values, 0, newValues, 0, values.length); newValues[values.length] = targetNode.valueFrom(version); targetNode.setProperty(JcrLexicon.PREDECESSORS, newValues, PropertyType.REFERENCE, false); removeVersionFromMergeFailedProperty(targetNode, version); targetNode.session().save(); }
@Override public boolean isCheckedOut() throws RepositoryException { AbstractJcrNode node = this; SessionCache cache = sessionCache(); ValueFactory<Boolean> booleanFactory = session.context().getValueFactories().getBooleanFactory(); while (node != null) { // If the node has an OPV of 'ignore' ... NodeDefinition defn = node.getDefinition(); if (defn.getOnParentVersion() == OnParentVersionAction.IGNORE) { // This node is not or cannot be checked in ... return true; } if (node.isNodeType(JcrMixLexicon.VERSIONABLE)) { Property prop = node.node().getProperty(JcrLexicon.IS_CHECKED_OUT, cache); // This prop can only be null if the node has not been saved since it was made versionable. return prop == null || booleanFactory.create(prop.getFirstValue()); } if (node.isRoot()) break; node = node.getParent(); } return true; }