use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class NodeImpl method resolveMergeConflict.
/**
* Internal method covering both {@link #doneMerge(Version)} and {@link #cancelMerge(Version)}.
*
* @param version
* @param done
* @throws VersionException
* @throws InvalidItemStateException
* @throws UnsupportedRepositoryOperationException
* @throws RepositoryException
*/
private void resolveMergeConflict(Version version, boolean done) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
checkIsVersionable();
checkHasPendingChanges();
checkIsLocked();
// check if checked out
if (!isCheckedOut()) {
String msg = "Unable to resolve merge conflict. Node is checked-in: " + safeGetJCRPath();
log.error(msg);
throw new VersionException(msg);
}
// check if version is in mergeFailed list
boolean isConflicting = false;
if (hasProperty(NameConstants.JCR_MERGEFAILED)) {
Value[] vals = getProperty(NameConstants.JCR_MERGEFAILED).getValues();
for (int i = 0; i < vals.length && !isConflicting; i++) {
isConflicting = vals[i].getString().equals(version.getUUID());
}
}
if (!isConflicting) {
String msg = "Unable to resolve merge conflict. Specified version is not in jcr:mergeFailed property: " + safeGetJCRPath();
log.error(msg);
throw new VersionException(msg);
}
NodeState versionState = session.getVersionState(version);
session.getVersionStateManager().resolveMergeConflict(getNodeState(), versionState, done);
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RestoreTest method testRestoreInvalidVersion.
/**
* VersionException expected on Node.restore(Version, boolean) if the
* specified version is not part of this node's version history.
*
* @throws RepositoryException
*/
@SuppressWarnings("deprecation")
public void testRestoreInvalidVersion() throws RepositoryException {
Version vNode2 = versionableNode2.checkin();
try {
versionableNode.restore(vNode2, true);
fail("VersionException expected on Node.restore(Version, boolean) if the specified version is not part of this node's version history.");
} catch (VersionException e) {
// ok
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RestoreTest method testRestoreInvalidVersionJcr2.
/**
* VersionException expected on restore if the
* specified version is not part of this node's version history.
*
* @throws RepositoryException
*/
public void testRestoreInvalidVersionJcr2() throws RepositoryException {
Version vNode2 = versionManager.checkin(versionableNode2.getPath());
try {
versionManager.restore(versionableNode.getPath(), vNode2, true);
fail("VersionException expected on Node.restore(Version, boolean) if the specified version is not part of this node's version history.");
} catch (VersionException e) {
// ok
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RestoreTest method testRestoreInvalidVersion2.
/**
* VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.
*
* @throws RepositoryException
*/
@SuppressWarnings("deprecation")
public void testRestoreInvalidVersion2() throws RepositoryException {
String invalidName;
do {
invalidName = createRandomString(3);
for (VersionIterator it = versionableNode.getVersionHistory().getAllVersions(); it.hasNext(); ) {
Version v = it.nextVersion();
if (invalidName.equals(v.getName())) {
invalidName = null;
break;
}
}
} while (invalidName == null);
try {
versionableNode.restore(invalidName, true);
fail("VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.");
} catch (VersionException e) {
// ok
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RestoreTest method testRestoreInvalidVersion2Jcr2.
/**
* VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.
*
* @throws RepositoryException
*/
public void testRestoreInvalidVersion2Jcr2() throws RepositoryException {
String invalidName;
do {
invalidName = createRandomString(3);
for (VersionIterator it = versionManager.getVersionHistory(versionableNode.getPath()).getAllVersions(); it.hasNext(); ) {
Version v = it.nextVersion();
if (invalidName.equals(v.getName())) {
invalidName = null;
break;
}
}
} while (invalidName == null);
try {
versionManager.restore(versionableNode.getPath(), invalidName, true);
fail("VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.");
} catch (VersionException e) {
// ok
}
}
Aggregations