/** * Return the name of the version represented by this object. * * @return the versions name */ public String getVersionLabel() throws RepositoryException { return this.state.getName(); }
@Override public String getVersionName() { try { return version.getName(); } catch (RepositoryException e) { log.warn("Could not determine version name"); } return "null"; }
/** * Test if restoring a node restores the correct property * * @throws RepositoryException */ public void testRestoreCorrectPropertyJcr2_3() throws RepositoryException { versionManager.restore(versionableNode.getPath(), version.getName(), true); String value = versionableNode.getProperty(propertyName1).getString(); assertEquals("Restoring a node must set the correct property.", propertyValue1, value); }
/** * Test if restoring a node works on checked-in node. * * @throws RepositoryException */ public void testRestoreOnCheckedInNodeJcr2_3() throws RepositoryException { versionManager.checkin(versionableNode.getPath()); versionManager.restore(versionableNode.getPath(), version.getName(), true); }
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(); }
/** * Restoring a node set the jcr:isCheckedOut property to false. * * @throws RepositoryException */ public void testRestoreSetsIsCheckedOutToFalseJcr3() throws RepositoryException { versionManager.restore(versionableNode.getPath(), version.getName(), true); assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath())); }
/** * Restoring a node set the jcr:isCheckedOut property to false. * * @throws RepositoryException */ public void testRestoreSetsIsCheckedOutToFalseJcr3() throws RepositoryException { versionManager.restore(versionableNode.getPath(), version.getName(), true); assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath())); }
/** * 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); }
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$ } }
/** * Test if VersionHistory.hasVersionLabel(Version, String) returns true, if the label * has beed successfully added before to the specified version. * * @throws RepositoryException * @see VersionHistory#hasVersionLabel(javax.jcr.version.Version, String) */ public void testHasVersionLabelForVersion() throws RepositoryException { vHistory.addVersionLabel(version.getName(), versionLabel, false); assertTrue("VersionHistory.hasVersionLabel(Version, String) must return true if the label has been sucessfully added.", vHistory.hasVersionLabel(version, versionLabel)); }
public static String getVersionId( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Node node ) throws RepositoryException { if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) { return JcrStringHelper.fileNameDecode( node.getParent().getName() ); } Version version = getBaseVersion( session, node ); return version != null ? JcrStringHelper.fileNameDecode( version.getName() ) : null; }
@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 ); } }
public void testMoveLabel3() throws RepositoryException { versionableNode.checkout(); Version v = versionableNode.checkin(); vHistory.addVersionLabel(version.getName(), versionLabel, false); vHistory.addVersionLabel(v.getName(), versionLabel, true); List<String> labels = Arrays.asList(vHistory.getVersionLabels(version)); assertFalse(labels.contains(versionLabel)); }
public void testRemovedLabel3() throws RepositoryException { vHistory.addVersionLabel(version.getName(), versionLabel, false); vHistory.removeVersionLabel(versionLabel); List<String> labels = Arrays.asList(vHistory.getVersionLabels(version)); assertFalse("VersionHistory.getVersionLabels(Version) must not return a removed label.",labels.contains(versionLabel)); }
/** * @see VersionHistory#removeVersionLabel(String) */ public void removeVersionLabel(String label) throws VersionException, RepositoryException { checkStatus(); Name qLabel = getQLabel(label); Version version = getVersionByLabel(qLabel); NodeState vState = getVersionState(version.getName()); // delegate to version manager that operates on workspace directly session.getVersionStateManager().removeVersionLabel((NodeState) getItemState(), vState, qLabel); }
/** * Returns the versionable node. */ public NodeIterator execute() throws Exception { Node n = getNode(); if (!n.isCheckedOut()) { log.info(n.getPath() + ":" + n.getBaseVersion().getName()); n.checkout(); } return wrapWithIterator(n); } }
@Test public void testGetVersionHistoryList() throws RepositoryException { // GIVEN Version version = versionManager.addVersion(node); // WHEN List<VersionInfo> versionList = VersionUtil.getVersionInfoList(node); // THEN assertEquals(1, versionList.size()); assertEquals(version.getName(), versionList.get(0).getVersionName()); }
/** * Returns the versionable node. */ public NodeIterator execute() throws Exception { Node n = getNode(); String name = n.getBaseVersion().getName(); String label = getRandomText(3); log.info(n.getPath() + ":" + name + " -> " + label); n.getVersionHistory().addVersionLabel(name, label, true); return wrapWithIterator(n); } }
@Test public void testExecute() throws Exception { // GIVEN VersionManager versionMan = VersionManager.getInstance(); versionMan.addVersion(node); AbstractJcrNodeAdapter item = new JcrNodeAdapter(node); RestorePreviousVersionAction action = new RestorePreviousVersionAction(definition, item, versionMan, subAppContext, eventBus, i18n); // WHEN action.execute(); // THEN assertEquals(versionMan.getBaseVersion(node).getName(), "1.0"); }