Refine search
/** * Test if UnsupportedRepositoryOperationException is thrown when calling * Node.getVersionHistory() on a non-versionable node. */ public void testGetVersionHistoryOnNonVersionableNodeJcr2() throws RepositoryException { try { versionManager.getVersionHistory(nonVersionableNode.getPath()); fail("Node.getVersionHistory() must throw UnsupportedRepositoryOperationException if the node is not versionable."); } catch (UnsupportedRepositoryOperationException e) { //success } }
boolean isVersionable( VersionManager vm, Node node ) throws RepositoryException { try { vm.getVersionHistory(node.getPath()); return true; } catch (UnsupportedRepositoryOperationException e) { return false; } }
/** * Test if VersionManager.checkin(String) adds another version to the VersionHistory * * @throws RepositoryException */ public void testCheckinCreatesNewVersionJcr2() throws RepositoryException { VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager(); String path = versionableNode.getPath(); long initialNumberOfVersions = getNumberOfVersions(versionManager.getVersionHistory(path)); versionManager.checkin(path); long numberOfVersions = getNumberOfVersions(versionManager.getVersionHistory(path)); assertTrue("Checkin must create a new Version in the VersionHistory.", numberOfVersions == initialNumberOfVersions + 1); }
/** * Test the restore of a versionable node using a label. * @throws RepositoryException */ public void testRestoreLabelJcr2() throws RepositoryException { // mark V1 with label test1 versionManager.getVersionHistory(versionableNode.getPath()).addVersionLabel(version.getName(), "test", true); // restore V1 via label. versionManager.restoreByLabel(versionableNode.getPath(), "test", true); String value = versionableNode.getProperty(propertyName1).getString(); assertEquals("Node.restore('test') not correctly restored", propertyValue1, value); }
/** * Test the restore of a versionable node using a label. * @throws RepositoryException */ public void testRestoreLabelJcr2() throws RepositoryException { // mark V1 with label test1 versionManager.getVersionHistory(versionableNode.getPath()).addVersionLabel(version.getName(), "test", true); // restore V1 via label. versionManager.restoreByLabel(versionableNode.getPath(), "test", true); String value = versionableNode.getProperty(propertyName1).getString(); assertEquals("Node.restore('test') not correctly restored", propertyValue1, value); }
/** * Test if VersionManager.checkin(String) adds another version to the VersionHistory * * @throws RepositoryException */ public void testCheckinCreatesNewVersionJcr2() throws RepositoryException { VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager(); String path = versionableNode.getPath(); long initialNumberOfVersions = getNumberOfVersions(versionManager.getVersionHistory(path)); versionManager.checkin(path); long numberOfVersions = getNumberOfVersions(versionManager.getVersionHistory(path)); assertTrue("Checkin must create a new Version in the VersionHistory.", numberOfVersions == initialNumberOfVersions + 1); }
protected void setUp() throws Exception { super.setUp(); versionManager = versionableNode.getSession().getWorkspace().getVersionManager(); version = versionManager.checkin(versionableNode.getPath()); vHistory = versionManager.getVersionHistory(versionableNode.getPath()); if (vHistory == null) { fail("VersionHistory must be created on persistent creation of a versionable node."); } }
protected void removeVersion(Node node, String versionName) { try { //VersionHistory versionHistory = node.getVersionHistory(); VersionHistory versionHistory = JcrUtils.getVersionManager(node.getSession()).getVersionHistory(node.getPath()); versionHistory.removeVersion(versionName); } catch (RepositoryException e) { throw new JcrMappingException("Could not remove version", e); } }
/** * Test if the root version does not have any predecessor versions. * * @throws RepositoryException */ public void testRootVersionHasNoPredecessorJcr2() throws RepositoryException { Version[] predec = versionableNode.getSession().getWorkspace().getVersionManager().getVersionHistory(versionableNode.getPath()).getRootVersion().getPredecessors(); assertTrue("The root version may not have any predecessors.", predec.length == 0); }
public static Object getVersionSummary( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final Serializable versionId ) throws RepositoryException { VersionManager vMgr = session.getWorkspace().getVersionManager(); Node fileNode = session.getNodeByIdentifier( fileId.toString() ); VersionHistory versionHistory = vMgr.getVersionHistory( fileNode.getPath() ); Version version = null; if ( versionId != null ) { version = versionHistory.getVersion( versionId.toString() ); } else { version = vMgr.getBaseVersion( fileNode.getPath() ); } return toVersionSummary( pentahoJcrConstants, versionHistory, version ); }
public static RepositoryFile getFileAtVersion( final Session session, final PentahoJcrConstants pentahoJcrConstants, final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable fileId, final Serializable versionId ) throws RepositoryException { Node fileNode = session.getNodeByIdentifier( fileId.toString() ); Version version = session.getWorkspace().getVersionManager().getVersionHistory( fileNode.getPath() ).getVersion( versionId .toString() ); return nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, getNodeAtVersion( pentahoJcrConstants, version ) ); }
/** * Returns the metadata regarding that identifies what transformer wrote this file's data. */ public static String getFileContentType( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final Serializable versionId ) throws RepositoryException { Assert.notNull( fileId ); Node fileNode = session.getNodeByIdentifier( fileId.toString() ); if ( versionId != null ) { Version version = session.getWorkspace().getVersionManager().getVersionHistory( fileNode.getPath() ).getVersion( versionId .toString() ); Node nodeAtVersion = getNodeAtVersion( pentahoJcrConstants, version ); return nodeAtVersion.getProperty( pentahoJcrConstants.getPHO_CONTENTTYPE() ).getString(); } return fileNode.getProperty( pentahoJcrConstants.getPHO_CONTENTTYPE() ).getString(); }
public ModuleHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
public AssetHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
public AssetHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
public ModuleHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
/** * Tests if VersionHistory.getVersionableIdentifier() returns the ID of the * corresponding versionable node. * @since JCR 2.9 */ public void testGetVersionableIdentifier() throws RepositoryException { VersionManager vm = versionableNode.getSession().getWorkspace().getVersionManager(); vm.checkpoint(versionableNode.getPath()); assertEquals("Method getVersionableIdentifier() must return the identifier of the corresponding Node.", vm.getVersionHistory(versionableNode.getPath()).getVersionableIdentifier(), versionableNode.getIdentifier()); } }
protected long getVersionSize(Node node) { try { //VersionHistory versionHistory = node.getVersionHistory(); VersionHistory versionHistory = JcrUtils.getVersionManager(node.getSession()).getVersionHistory(node.getPath()); return versionHistory.getAllVersions().getSize() - 1; } catch (RepositoryException e) { throw new JcrMappingException("Could not get version history size", e); } }
/** * Test if the a label added with VersionHistory.addVersionLabel(String, * String, boolean) corresponds to adding a reference property to the * jcr:versionLabels node of this history node, with the label as name of * the property, and the reference targeting the version. * * @see VersionHistory#addVersionLabel(String, String, boolean) */ public void testAddVersionCheckVersionLabelsNodeJcr2() throws RepositoryException { vHistory.addVersionLabel(version.getName(), versionLabel, false); // get jcr:versionLabels node vHistory = versionableNode.getSession().getWorkspace().getVersionManager().getVersionHistory(versionableNode.getPath()); Node versionLabelNode = vHistory.getNode(jcrVersionLabels); assertTrue("The version label that has been successfully added must be present in the node '" + jcrVersionLabels + "'.", versionLabelNode.getProperty(versionLabel).getString().equals(version.getUUID())); }
/** * Test that the initial base version after creation of a versionable node * points to the root version. * * @throws javax.jcr.RepositoryException */ public void testInitialBaseVersionPointsToRootVersionJcr2() throws RepositoryException { VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager(); String path = versionableNode.getPath(); Version rV = versionManager.getVersionHistory(path).getRootVersion(); Version bV = versionManager.getBaseVersion(path); assertTrue("After creation of a versionable node the node's baseVersion must point to the rootVersion in the version history.", rV.isSame(bV)); }