/** * Obtain a string identifying this node, usually for error or logging purposes. This method never throws an exception. * * @return the location string; never null */ protected final String location() { try { return getPath(); } catch (Throwable t) { return key.toString(); } }
/** * Obtain a string identifying this node, usually for error or logging purposes. This method never throws an exception. * * @return the location string; never null */ protected final String location() { try { return getPath(); } catch (Throwable t) { return key.toString(); } }
public Lock getLock( AbstractJcrNode node ) throws LockException, AccessDeniedException, RepositoryException { ModeShapeLock lock = getLowestLockAlongPath(node, false); if (lock != null) return lock.lockFor(session); throw new LockException(JcrI18n.notLocked.text(node.getPath())); }
public Lock getLock( AbstractJcrNode node ) throws LockException, AccessDeniedException, RepositoryException { ModeShapeLock lock = getLowestLockAlongPath(node, false); if (lock != null) return lock.lockFor(session); throw new LockException(JcrI18n.notLocked.text(node.getPath())); }
@Override public Node nodeFrom( ChildReference ref ) { try { AbstractJcrNode node = session.node(ref.getKey(), null, parentKey); if (checkPermission && !node.isExternal() && !session.hasPermission(node.getPath(), ModeShapePermissions.READ)) { return null; } return node; } catch (RepositoryException e) { return null; } } }
/** * Throw a {@link ConstraintViolationException} if this node is protected (based on the its node definition). * * @throws ConstraintViolationException if this node's definition indicates that the node is protected * @throws RepositoryException if an error occurs retrieving the definition for this node */ private void checkNotProtected() throws ConstraintViolationException, RepositoryException { if (getDefinition().isProtected()) { throw new ConstraintViolationException(JcrI18n.cannotRemoveItemWithProtectedDefinition.text(getPath())); } }
/** * Throw a {@link ConstraintViolationException} if this node is protected (based on the its node definition). * * @throws ConstraintViolationException if this node's definition indicates that the node is protected * @throws RepositoryException if an error occurs retrieving the definition for this node */ private void checkNotProtected() throws ConstraintViolationException, RepositoryException { if (getDefinition().isProtected()) { throw new ConstraintViolationException(JcrI18n.cannotRemoveItemWithProtectedDefinition.text(getPath())); } }
@Override public Node nodeFrom( ChildReference ref ) { try { AbstractJcrNode node = session.node(ref.getKey(), null, parentKey); if (checkPermission && !node.isExternal() && !session.hasPermission(node.getPath(), ModeShapePermissions.READ)) { return null; } return node; } catch (RepositoryException e) { return null; } } }
@Test public void shouldProvidePath() throws Exception { assertThat(rootNode.getPath(), is("/")); } }
@Override public void refresh() throws LockException { String token = lockToken(); if (!lockManager.hasLockToken(token)) { String location = null; try { location = node.getPath(); } catch (RepositoryException e) { location = lockedNodeKey.toString(); } throw new LockException(JcrI18n.notLocked.text(location)); } }
@Override public void refresh() throws LockException { String token = lockToken(); if (!lockManager.hasLockToken(token)) { String location = null; try { location = node.getPath(); } catch (RepositoryException e) { location = lockedNodeKey.toString(); } throw new LockException(JcrI18n.notLocked.text(location)); } }
@Test public void shouldProvidePath() throws Exception { assertThat(altimaModel.getPath(), is(altima.getPath() + "/car:model")); }
@Override public void restore( Version version, boolean removeExisting ) throws VersionException, ItemExistsException, InvalidItemStateException, UnsupportedRepositoryOperationException, LockException, RepositoryException { try { checkNotProtected(); } catch (ConstraintViolationException cve) { throw new UnsupportedRepositoryOperationException(cve); } versionManager().restoreAtAbsPath(getPath(), version, removeExisting, false); }
@Test public void shouldHavePath() throws Exception { assertThat(altima.getPath(), is("/Cars/Hybrid/Nissan Altima")); javax.jcr.Node altima2 = hybrid.addNode("Nissan Altima"); try { assertThat(altima2, is(notNullValue())); assertThat(altima2.getPath(), is("/Cars/Hybrid/Nissan Altima[2]")); } finally { altima2.remove(); // remove the node we added in this test to not interfere with other tests } }
@Override public void restore( Version version, boolean removeExisting ) throws VersionException, ItemExistsException, InvalidItemStateException, UnsupportedRepositoryOperationException, LockException, RepositoryException { try { checkNotProtected(); } catch (ConstraintViolationException cve) { throw new UnsupportedRepositoryOperationException(cve); } versionManager().restoreAtAbsPath(getPath(), version, removeExisting, false); }
@Override public String toString() { NodeHandler parent = parentHandler(); if (parent != null) { return parent.toString() + "/" + name(); } try { return node().getPath(); } catch (Throwable e) { try { return node().toString(); } catch (SAXException e2) { throw new SystemFailureException(e2); } } } }
@Override public ContentHandler getImportContentHandler( String parentAbsPath, int uuidBehavior ) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException { checkLive(); // Find the parent path ... AbstractJcrNode parent = getNode(parentAbsPath); if (!parent.isCheckedOut()) { throw new VersionException(JcrI18n.nodeIsCheckedIn.text(parent.getPath())); } boolean retainLifecycleInfo = getRepository().getDescriptorValue(Repository.OPTION_LIFECYCLE_SUPPORTED).getBoolean(); boolean retainRetentionInfo = getRepository().getDescriptorValue(Repository.OPTION_RETENTION_SUPPORTED).getBoolean(); return new JcrContentHandler(this, parent, uuidBehavior, false, retainRetentionInfo, retainLifecycleInfo); }
@Override public JcrVersionNode getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException { checkSession(); if (!hasProperty(JcrLexicon.BASE_VERSION)) { throw new UnsupportedRepositoryOperationException(JcrI18n.requiresVersionable.text()); } NodeKey baseVersionKey = ((NodeKeyReference)getProperty(JcrLexicon.BASE_VERSION).getValue().value()).getNodeKey(); try { return (JcrVersionNode)session().node(baseVersionKey, null); } catch (NodeNotFoundInParentException | ItemNotFoundException e) { // this should only happen if multiple threads are performing non-atomic checkin/checkout flows on the same node // see MODE-2418 throw new VersionException(JcrI18n.cannotLocateBaseVersion.text(baseVersionKey, getPath()), e); } }
@Override public JcrVersionNode getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException { checkSession(); if (!hasProperty(JcrLexicon.BASE_VERSION)) { throw new UnsupportedRepositoryOperationException(JcrI18n.requiresVersionable.text()); } NodeKey baseVersionKey = ((NodeKeyReference)getProperty(JcrLexicon.BASE_VERSION).getValue().value()).getNodeKey(); try { return (JcrVersionNode)session().node(baseVersionKey, null); } catch (NodeNotFoundInParentException | ItemNotFoundException e) { // this should only happen if multiple threads are performing non-atomic checkin/checkout flows on the same node // see MODE-2418 throw new VersionException(JcrI18n.cannotLocateBaseVersion.text(baseVersionKey, getPath()), e); } }
@Test @FixFor( "MODE-2424" ) public void shouldAllowAddingMixinOnLockedNodeForLockOwner() throws Exception { final AbstractJcrNode testNode = session.getRootNode().addNode("test"); final String path = testNode.getPath(); testNode.addMixin("mix:lockable"); session.save(); session.getWorkspace().getLockManager().lock(path, false, true, Long.MAX_VALUE, session.getUserID()); testNode.addMixin("mix:created"); session.save(); }