@Nonnull String label,
@Nonnull String versionName)
throws CommitFailedException {
NodeBuilder labels = getVersionLabelsFor(checkNotNull(historyRelPath));
if (labels.hasProperty(checkNotNull(label))) {
throw new CommitFailedException(CommitFailedException.LABEL_EXISTS,
VersionExceptionCode.LABEL_EXISTS.ordinal(),
"Version label " + label + " already exists on this version history");
}
NodeBuilder history = resolve(versionStorageNode, historyRelPath);
if (checkNotNull(versionName).equals(JCR_ROOTVERSION)
|| !history.hasChildNode(checkNotNull(versionName))) {
throw new CommitFailedException(CommitFailedException.VERSION,
VersionExceptionCode.NO_SUCH_VERSION.ordinal(),
"Not a valid version on this history: " + versionName);
}
String uuid = uuidFromNode(history.getChildNode(versionName));
labels.setProperty(label, uuid, Type.REFERENCE);