use of javax.jcr.version.VersionException in project jackrabbit-oak by apache.
the class NodeImpl method removeMixin.
@Override
public void removeMixin(final String mixinName) throws RepositoryException {
final String oakTypeName = getOakName(checkNotNull(mixinName));
sessionDelegate.performVoid(new ItemWriteOperation<Void>("removeMixin") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
if (!isCheckedOut()) {
throw new VersionException(format("Cannot remove mixin type. Node [%s] is checked in.", getNodePath()));
}
// check for NODE_TYPE_MANAGEMENT permission here as we cannot
// distinguish between a combination of removeMixin and addMixin
// and Node#remove plus subsequent addNode when it comes to
// autocreated properties like jcr:create, jcr:uuid and so forth.
Set<String> mixins = newLinkedHashSet(getNames(dlg.getTree(), JCR_MIXINTYPES));
if (!mixins.isEmpty() && mixins.remove(getOakName(mixinName))) {
PropertyState prop = PropertyStates.createProperty(JCR_MIXINTYPES, mixins, NAMES);
sessionContext.getAccessManager().checkPermissions(dlg.getTree(), prop, Permissions.NODE_TYPE_MANAGEMENT);
}
}
@Override
public void performVoid() throws RepositoryException {
dlg.removeMixin(oakTypeName);
}
});
}
use of javax.jcr.version.VersionException in project jackrabbit-oak by apache.
the class OpvAbortTest method testDirectChild.
public void testDirectChild() throws Exception {
testRootNode.addMixin("OpvAbortTest");
Node n = testRootNode.addNode("child", NodeTypeConstants.NT_OAK_UNSTRUCTURED);
assertEquals(OnParentVersionAction.ABORT, n.getDefinition().getOnParentVersion());
superuser.save();
try {
vMgr.checkpoint(testRootNode.getPath());
fail();
} catch (VersionException e) {
// success
} finally {
superuser.refresh(false);
}
}
use of javax.jcr.version.VersionException in project jackrabbit-oak by apache.
the class VersionableTest method testReadOnlyAfterCheckin.
public void testReadOnlyAfterCheckin() throws RepositoryException {
Node node = testRootNode.addNode(nodeName1, testNodeType);
node.addMixin(mixVersionable);
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
if (!node.isCheckedOut()) {
vMgr.checkout(node.getPath());
}
superuser.refresh(false);
node.setProperty(propertyName1, "foo");
superuser.save();
vMgr.checkin(node.getPath());
try {
node.setProperty(propertyName1, "bar");
fail("setProperty() must fail on a checked-in node");
} catch (VersionException e) {
// expected
}
try {
node.setProperty(propertyName1, (String) null);
fail("setProperty(..., null) must fail on a checked-in node");
} catch (VersionException e) {
// expected
}
try {
Property prop = node.getProperty(propertyName1);
assertNotNull(prop);
prop.setValue("bar");
fail("Property.setValue() must fail on a checked-in node");
} catch (VersionException e) {
// expected
}
try {
Property prop = node.getProperty(propertyName1);
assertNotNull(prop);
prop.remove();
fail("Property.remove() must fail on a checked-in node");
} catch (VersionException e) {
// expected
}
}
Aggregations