use of javax.jcr.version.Version in project jackrabbit by apache.
the class AbstractVersionManagementTest method testRemoveVersion.
public void testRemoveVersion() throws RepositoryException, NotExecutableException {
Node trn = getTestNode();
Node n = createVersionableNode(testRootNode);
modifyPrivileges(trn.getPath(), Privilege.JCR_VERSION_MANAGEMENT, true);
// test session should now be able to create versionable nodes, checkout
// and checkin them, read the version/v-histories.
Node testNode = trn.getNode(nodeName1);
Version v = testNode.checkin();
testNode.checkout();
testNode.checkin();
// remove ability to edit version information
// -> VersionHistory.removeVersion must not be allowed.
modifyPrivileges(trn.getPath(), Privilege.JCR_VERSION_MANAGEMENT, false);
try {
testNode.getVersionHistory().removeVersion(v.getName());
fail("TestSession without remove privilege on the v-storage must not be able to remove a version.");
} catch (AccessDeniedException e) {
// success
log.debug(e.getMessage());
}
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionHistoryImpl method getVersionByLabel.
/**
*
* @param qLabel
* @return
* @throws VersionException
* @throws RepositoryException
*/
private Version getVersionByLabel(Name qLabel) throws VersionException, RepositoryException {
refreshEntry(labelNodeEntry);
// retrieve reference property value -> and retrieve referenced node
PropertyEntry pEntry = labelNodeEntry.getPropertyEntry(qLabel, true);
if (pEntry == null) {
throw new VersionException("Version with label '" + qLabel + "' does not exist.");
}
Node version = ((Property) getItemManager().getItem(pEntry)).getNode();
return (Version) version;
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionHistoryImpl method getVersion.
/**
* @see VersionHistory#getVersion(String)
*/
public Version getVersion(String versionName) throws VersionException, RepositoryException {
checkStatus();
NodeState vState = getVersionState(versionName);
return (Version) getItemManager().getItem(vState.getHierarchyEntry());
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionHistoryImpl method removeVersionLabel.
/**
* @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);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RepositoryServiceImpl method restore.
/**
* {@inheritDoc}
*/
public void restore(final SessionInfo sessionInfo, final NodeId[] versionIds, final boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException {
final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
executeWithLocalEvents(new Callable() {
public Object run() throws RepositoryException {
Version[] versions = new Version[versionIds.length];
for (int i = 0; i < versions.length; i++) {
Node n = getNode(versionIds[i], sInfo);
if (n instanceof Version) {
versions[i] = (Version) n;
} else {
throw new RepositoryException(n.getPath() + " does not reference a Version node");
}
}
sInfo.getSession().getWorkspace().restore(versions, removeExisting);
return null;
}
}, sInfo);
}
Aggregations