/** * @see javax.jcr.Node#getBaseVersion() */ @Override @NotNull public Version getBaseVersion() throws RepositoryException { return getVersionManager().getBaseVersion(getPath()); }
/** * @see javax.jcr.Node#getBaseVersion() */ @Override @Nonnull public Version getBaseVersion() throws RepositoryException { return getVersionManager().getBaseVersion(getPath()); }
/** * @see javax.jcr.Node#getBaseVersion() */ @Override @NotNull public Version getBaseVersion() throws RepositoryException { return getVersionManager().getBaseVersion(getPath()); }
public static Serializable getBaseVersionId( final Session session, final Serializable fileId ) throws RepositoryException { Node node = session.getNodeByIdentifier( fileId.toString() ); return session.getWorkspace().getVersionManager().getBaseVersion( node.getPath() ).getName(); }
public static Version getBaseVersion(Node node) { String nodeName = null; if (! isVersionable(node)) { return null; } try { nodeName = node.getName(); return JcrVersionUtil.getVersionManager(node.getSession()).getBaseVersion(node.getPath()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Unable to find Base Version for " + nodeName, e); } }
/** * Tests if <code>Version.getBaseVersion()</code> throws an {@link * javax.jcr.UnsupportedRepositoryOperationException} */ public void testGetBaseVersionJcr2() throws Exception { try { versionManager.getBaseVersion(version.getPath()); fail("Version.getBaseVersion() did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
private static void preventLostUpdate( final Session session, final PentahoJcrConstants pentahoJcrConstants, final RepositoryFile file ) throws RepositoryException { Node fileNode = session.getNodeByIdentifier( file.getId().toString() ); // guard against using a file retrieved from a more lenient session inside a more strict session Assert.notNull( fileNode ); if ( isVersioned( session, pentahoJcrConstants, fileNode ) ) { Assert.notNull( file.getVersionId(), "updating a versioned file requires a non-null version id" ); //$NON-NLS-1$ Assert.state( session.getWorkspace().getVersionManager().getBaseVersion( fileNode.getPath() ).getName().equals( file.getVersionId().toString() ), "update to this file has occurred since its last read" ); //$NON-NLS-1$ } }
@Override public JcrDocument getJcrNode(Node node) throws RepositoryException { if (node.isNodeType(NodeType.NT_VERSION)) { return new JcrMsVersionNode(node, (Version) node, typeManager, pathManager, typeHandlerManager); } VersionManager versionManager = node.getSession().getWorkspace().getVersionManager(); Version version = versionManager.getBaseVersion(node.getPath()); return new JcrMsVersion(node, version, typeManager, pathManager, typeHandlerManager); }
/** * Test if restoring a node sets the jcr:baseVersion property correctly. * * @throws javax.jcr.RepositoryException */ public void testRestoreSetsBaseVersionJcr2_2() throws RepositoryException { versionManager.restore(version, true); Version baseV = versionManager.getBaseVersion(versionableNode.getPath()); assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV)); }
/** * Test if restoring a node sets the jcr:baseVersion property correctly. * * @throws javax.jcr.RepositoryException */ public void testRestoreSetsBaseVersionJcr2() throws RepositoryException { versionManager.restore(version, true); Version baseV = versionManager.getBaseVersion(versionableNode.getPath()); assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV)); }
/** * Test if restoring a node sets the jcr:baseVersion property correctly. * * @throws javax.jcr.RepositoryException */ public void testRestoreSetsBaseVersionJcr2_3() throws RepositoryException { versionManager.restore(versionableNode.getPath(), version.getName(), true); Version baseV = versionManager.getBaseVersion(versionableNode.getPath()); assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV)); }
public RemoteVersion getBaseVersion(String absPath) throws RepositoryException, RemoteException { try { return getFactory().getRemoteVersion( manager.getBaseVersion(absPath)); } catch (RepositoryException e) { throw getRepositoryException(e); } }
@Test public void testVersionId_Success() throws Exception { Version version = mock( Version.class ); when( version.getName() ).thenReturn( VERSION_NAME_TEST ); when( vmanagerMock.getBaseVersion( anyString() ) ).thenReturn( version ); try { String versionId = JcrRepositoryFileUtils.getVersionId( sessionMock, pJcrConstMock, nodeMock ); assertTrue( VERSION_NAME_TEST.equals( versionId ) ); } catch ( Exception e ) { fail( "No exception shold be here but it is: " + e ); } }
@SuppressWarnings( "deprecation" ) protected Version baseVersion( Node node ) throws RepositoryException { if (useDeprecatedApi()) return node.getBaseVersion(); return session.getWorkspace().getVersionManager().getBaseVersion(node.getPath()); }
@Test public void testVersionIdIsNull_WhenJCRReturnsNull() throws Exception { when( vmanagerMock.getBaseVersion( anyString() ) ).thenReturn( null ); try { String versionId = JcrRepositoryFileUtils.getVersionId( sessionMock, pJcrConstMock, nodeMock ); assertNull( versionId ); } catch ( Exception e ) { fail( "No exception shold be here but it is: " + e ); } }
public void testFrozenNode() throws RepositoryException { Node n = testRootNode.addNode(nodeName1, testNodeType); n.addMixin(mixVersionable); Node child = n.addNode(nodeName2, ntUnstructured); superuser.save(); VersionManager vMgr = superuser.getWorkspace().getVersionManager(); vMgr.checkpoint(n.getPath()); Version v = vMgr.getBaseVersion(n.getPath()); Node frozenChild = v.getFrozenNode().getNode(child.getName()); assertEquals(ntFrozenNode, frozenChild.getPrimaryNodeType().getName()); }
public void testGetNodeByIdentifier() throws RepositoryException { Node n = testRootNode.addNode(nodeName1, testNodeType); n.addMixin(mixVersionable); superuser.save(); VersionManager vMgr = superuser.getWorkspace().getVersionManager(); String id = vMgr.getBaseVersion(n.getPath()).getIdentifier(); assertTrue("Session.getNodeByIdentifier() did not return Version object for a nt:version node.", superuser.getNodeByIdentifier(id) instanceof Version); }
@SuppressWarnings("deprecation") public void testGetNodeByUUID() throws RepositoryException { Node n = testRootNode.addNode(nodeName1, testNodeType); n.addMixin(mixVersionable); superuser.save(); VersionManager vMgr = superuser.getWorkspace().getVersionManager(); String uuid = vMgr.getBaseVersion(n.getPath()).getUUID(); assertTrue("Session.getNodeByUUID() did not return Version object for a nt:version node.", superuser.getNodeByUUID(uuid) instanceof Version); }
@Test public void testRepositoryExceptionThrows() throws Exception { when( vmanagerMock.getBaseVersion( anyString() ) ).thenThrow( new RepositoryException( REPOSITORY_EXCEPTION_TEST_MESSAGE ) ); exception.expect( RepositoryException.class ); exception.expectMessage( REPOSITORY_EXCEPTION_TEST_MESSAGE ); JcrRepositoryFileUtils.getVersionId( sessionMock, pJcrConstMock, nodeMock ); }
/** * @since oak */ @Test public void testGetBaseVersion() throws Exception { // version information must still be accessible Version base = testSession.getNode(versionablePath).getBaseVersion(); Version base2 = testSession.getWorkspace().getVersionManager().getBaseVersion(versionablePath); }