use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionHistoryImpl method getVersionByLabel.
/**
* @see javax.jcr.version.VersionHistory#getVersionByLabel(String)
*/
public javax.jcr.version.Version getVersionByLabel(String label) throws RepositoryException {
try {
Name qLabel = sessionContext.getQName(label);
InternalVersion v = getInternalVersionHistory().getVersionByLabel(qLabel);
if (v == null) {
throw new VersionException("No version with label '" + label + "' exists in this version history.");
}
return (Version) sessionContext.getSessionImpl().getNodeById(v.getId());
} catch (NameException e) {
throw new VersionException(e);
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionHistoryImpl method removeVersionLabel.
/**
* @see javax.jcr.version.VersionHistory#removeVersionLabel(String)
*/
public void removeVersionLabel(String label) throws RepositoryException {
try {
// check permissions
checkVersionManagementPermission();
InternalVersion existing = sessionContext.getSessionImpl().getInternalVersionManager().setVersionLabel(getSession(), getInternalVersionHistory(), null, sessionContext.getQName(label), true);
if (existing == null) {
throw new VersionException("No version with label '" + label + "' exists in this version history.");
}
} catch (NameException e) {
throw new VersionException(e);
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionHistoryImpl method getVersion.
/**
* @see javax.jcr.version.VersionHistory#getVersion(String)
*/
public javax.jcr.version.Version getVersion(String versionName) throws VersionException, RepositoryException {
try {
Name name = sessionContext.getQName(versionName);
InternalVersion v = getInternalVersionHistory().getVersion(name);
if (v == null) {
throw new VersionException("No version with name '" + versionName + "' exists in this version history.");
}
return (Version) sessionContext.getSessionImpl().getNodeById(v.getId());
} catch (NameException e) {
throw new VersionException(e);
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionHistoryImpl method addVersionLabel.
/**
* @see javax.jcr.version.VersionHistory#addVersionLabel(String, String, boolean)
*/
public void addVersionLabel(String versionName, String label, boolean move) throws VersionException, RepositoryException {
try {
// check permissions
checkVersionManagementPermission();
sessionContext.getSessionImpl().getInternalVersionManager().setVersionLabel(getSession(), getInternalVersionHistory(), sessionContext.getQName(versionName), sessionContext.getQName(label), move);
} catch (NameException e) {
throw new VersionException(e);
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class NodeAddMixinTest method testCheckedIn.
/**
* Tests if <code>Node.addMixin(String mixinName)</code> throws a
* <code>VersionException</code> if <code>Node</code> is checked-in.
* <p>
* The test creates a node <code>nodeName1</code> of type
* <code>testNodeType</code> under <code>testRoot</code> and checks it in.
* Then the test tries to add a mixin to <code>nodeName1</code>.
*/
public void testCheckedIn() throws NotExecutableException, RepositoryException {
Session session = testRootNode.getSession();
if (!isSupported(Repository.OPTION_VERSIONING_SUPPORTED)) {
throw new NotExecutableException("Versioning is not supported.");
}
// create a node that is versionable
Node node = testRootNode.addNode(nodeName1, testNodeType);
// or try to make it versionable if it is not
ensureMixinType(node, mixVersionable);
testRootNode.getSession().save();
String mixinName = NodeMixinUtil.getAddableMixinName(session, node);
if (mixinName == null || node.isNodeType(mixinName)) {
throw new NotExecutableException("No testable mixin node type found");
}
node.checkin();
try {
node.addMixin(mixinName);
fail("Node.addMixin(String mixinName) must throw a VersionException " + "if the node is checked-in.");
} catch (VersionException e) {
// success
}
}
Aggregations