use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class ItemSaveOperation method processShareableNodes.
/**
* Process all items given in iterator and check whether <code>mix:shareable</code>
* or (some derived node type) has been added or removed:
* <ul>
* <li>If the mixin <code>mix:shareable</code> (or some derived node type),
* then initialize the shared set inside the state.</li>
* <li>If the mixin <code>mix:shareable</code> (or some derived node type)
* has been removed, throw.</li>
* </ul>
*/
private void processShareableNodes(NodeTypeRegistry registry, Iterable<ItemState> states) throws RepositoryException {
for (ItemState is : states) {
if (is.isNode()) {
NodeState ns = (NodeState) is;
boolean wasShareable = false;
if (ns.hasOverlayedState()) {
NodeState old = (NodeState) ns.getOverlayedState();
EffectiveNodeType ntOld = getEffectiveNodeType(registry, old);
wasShareable = ntOld.includesNodeType(NameConstants.MIX_SHAREABLE);
}
EffectiveNodeType ntNew = getEffectiveNodeType(registry, ns);
boolean isShareable = ntNew.includesNodeType(NameConstants.MIX_SHAREABLE);
if (!wasShareable && isShareable) {
// mix:shareable has been added
ns.addShare(ns.getParentId());
} else if (wasShareable && !isShareable) {
// mix:shareable has been removed: not supported
String msg = "Removing mix:shareable is not supported.";
log.debug(msg);
throw new UnsupportedRepositoryOperationException(msg);
}
}
}
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class RemoveVersionTest method setUp.
protected void setUp() throws Exception {
super.setUp();
// create 1.0
Version testV = versionableNode.checkin();
versionableNode.checkout();
// create 1.1
versionableNode.checkin();
versionableNode.checkout();
// create 1.2
versionableNode.checkin();
try {
versionableNode.getVersionHistory().removeVersion(testV.getName());
} catch (UnsupportedRepositoryOperationException e) {
throw new NotExecutableException("Removing version is not supported: " + e.getMessage());
}
versionableNode.checkout();
version = versionableNode.checkin();
// create a second version
versionableNode.checkout();
version2 = versionableNode.checkin();
vHistory = versionableNode.getVersionHistory();
// build a second versionable node below the testroot
try {
versionableNode2 = createVersionableNode(testRootNode, nodeName2, versionableNodeType);
} catch (RepositoryException e) {
fail("Failed to create a second versionable node: " + e.getMessage());
}
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class WorkspaceTest method testDeleteWorkspace.
public void testDeleteWorkspace() throws Exception {
try {
Workspace wsp = superuser.getWorkspace();
String name = getNewWorkspaceName(wsp);
wsp.createWorkspace(name, wsp.getName());
List<String> wsps = Arrays.asList(wsp.getAccessibleWorkspaceNames());
assertTrue(wsps.contains(name));
wsp.deleteWorkspace(name);
wsps = Arrays.asList(wsp.getAccessibleWorkspaceNames());
assertFalse(wsps.contains(name));
Session s = null;
try {
s = getHelper().getSuperuserSession(name);
fail(name + " has been deleted.");
} catch (NoSuchWorkspaceException e) {
// success
} finally {
if (s != null) {
s.logout();
}
}
} catch (UnsupportedRepositoryOperationException e) {
throw new NotExecutableException();
} catch (UnsupportedOperationException e) {
throw new NotExecutableException();
}
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class ConfigurationsTest method testCheckinConfigFailsWithUnversionedChild.
public void testCheckinConfigFailsWithUnversionedChild() throws Exception {
Node config = vm.createConfiguration(versionableNode.getPath());
try {
vm.checkin(config.getPath());
fail("Checkin configuration must fail one of the recorded versions is not versioned.");
} catch (UnsupportedRepositoryOperationException e) {
// ignore
}
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class CheckinTest method testCheckinNonVersionableNodeJcr2.
/**
* Test calling VersionManager.checkin(P) with the path P resolving to
* a non-versionable node.
*
* @throws RepositoryException
*/
public void testCheckinNonVersionableNodeJcr2() throws RepositoryException {
try {
VersionManager versionManager = nonVersionableNode.getSession().getWorkspace().getVersionManager();
String path = nonVersionableNode.getPath();
versionManager.checkin(path);
fail("VersionManager.checkin(P) must throw UnsupportedRepositoryOperationException if the path P resolves to a non-versionable node.");
} catch (UnsupportedRepositoryOperationException e) {
//success
}
}
Aggregations