VersionHistory history = session.getWorkspace().getVersionManager().getVersionHistory("/my/node/path"); // To iterate over all versions VersionIterator versions = history.getAllVersions(); while (versions.hasNext()) { Version version = versions.nextVersion(); } // Obtain version per name Version mySpecificVersion = history.getVersion("myVersion"); //Obtain version per label Version labelisedVersion = history.getVersionByLabel("myLabel"); String myVersionPropertyValue = labelisedVersion.getFrozenNode().getProperty("myProperty").getString();
/** * Checks if the specified version belongs to this <code>VersionHistory</code>. * This method throws <code>VersionException</code> if {@link Version#getContainingHistory()} * is not the same item than this <code>VersionHistory</code>. * * @param version * @throws javax.jcr.version.VersionException * @throws javax.jcr.RepositoryException */ private void checkValidVersion(Version version) throws VersionException, RepositoryException { if (!version.getContainingHistory().isSame(this)) { throw new VersionException("Specified version '" + version.getName() + "' is not part of this history."); } }
/** * Get containing version history. * * @return version history associated to this version */ public VersionHistory getContainingHistory() throws RepositoryException { return this.state.getContainingHistory(); }
private void removeAllVersions(VersionHistory history) throws RepositoryException { // delete all versions of node (to delete references to // files) VersionIterator it = history.getAllVersions(); while (it.hasNext()) { Version version = it.nextVersion(); history.removeVersion(version.getName()); } }
/** * Return the name of the version represented by this object. * * @return the versions name */ public String getVersionLabel() throws RepositoryException { return this.state.getName(); }
/** * Get creation date of this version. * * @return creation date as calendar */ public Calendar getCreated() throws RepositoryException { return this.state.getCreated(); }
/** * @inheritDoc */ public String[] getVersionLabels() throws RepositoryException { return versionHistory.getVersionLabels(); }
/** * Test if restoring a node works on checked-out node. * * @throws RepositoryException */ public void testRestoreOnCheckedOutNodeJcr2() throws RepositoryException { versionManager.restore(version, true); }
/** * @inheritDoc */ public void removeVersion(String versionName) throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException { versionHistory.removeVersion(versionName); }
/** * @inheritDoc */ public void addVersionLabel(String versionName, String label, boolean moveLabel) throws VersionException, RepositoryException { versionHistory.addVersionLabel(versionName, label, moveLabel); }
@Override public boolean isCurrent() { try { Version[] successors = version.getSuccessors(); if (successors == null || successors.length == 0) { return true; } } catch (RepositoryException e) { // no-op } return false; }
/** * Sets the on-parent-version status of the child item. * * @param opv an <code>int</code> constant member of <code>OnParentVersionAction</code>. * @throws IllegalArgumentException If the given <code>opv</code> flag isn't valid. */ public void setOnParentVersion(int opv) { // validate the given opv-action OnParentVersionAction.nameFromValue(opv); this.opv = opv; }
/** * Returns size for all versions from all workspaces, unlike {@link #getSize()} that returns filtered results by workspace. */ public long getUnfilteredSize() { return versionIterator.getSize(); }
/** * @inheritDoc */ public void removeVersionLabel(String label) throws VersionException, RepositoryException { versionHistory.removeVersionLabel(label); }
/** * @inheritDoc */ public String getVersionableUUID() throws RepositoryException { return versionHistory.getVersionableUUID(); }
/** * @inheritDoc */ public boolean hasVersionLabel(String label) throws RepositoryException { return versionHistory.hasVersionLabel(label); }
/** * Checks if the specified version belongs to this <code>VersionHistory</code>. * This method throws <code>VersionException</code> if {@link Version#getContainingHistory()} * is not the same item than this <code>VersionHistory</code>. * * @param version * @throws javax.jcr.version.VersionException * @throws javax.jcr.RepositoryException */ private void checkValidVersion(Version version) throws VersionException, RepositoryException { if (!version.getContainingHistory().isSame(this)) { throw new VersionException("Specified version '" + version.getName() + "' is not part of this history."); } }
/** * @inheritDoc */ public Calendar getCreated() throws RepositoryException { return version.getCreated(); }
@Override public boolean isCurrent() { try { Version[] successors = version.getSuccessors(); if (successors == null || successors.length == 0) { return true; } } catch (RepositoryException e) { // no-op } return false; }
/** * Sets the on-parent-version status of the child item. * * @param opv an <code>int</code> constant member of <code>OnParentVersionAction</code>. * @throws IllegalArgumentException If the given <code>opv</code> flag isn't valid. */ public void setOnParentVersion(int opv) { // validate the given opv-action OnParentVersionAction.nameFromValue(opv); this.opv = opv; }