use of javax.jcr.nodetype.NoSuchNodeTypeException in project jackrabbit by apache.
the class AbstractVersionTest method setUp.
protected void setUp() throws Exception {
super.setUp();
super.checkSupportedOption(Repository.OPTION_SIMPLE_VERSIONING_SUPPORTED);
NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
// assert that this repository support versioning
try {
NodeType versionableNt = ntMgr.getNodeType(mixSimpleVersionable);
if (versionableNt == null) {
fail("Repository does not support Versioning: mixin nodetype 'mix:simpleVersionable' is missing.");
}
} catch (NoSuchNodeTypeException e) {
fail("Repository does not support Versioning: mixin nodetype 'mix:simpleVersionable' is missing.");
}
// retrieve versionable nodetype
String versionableNodeTypeName = getProperty("versionableNodeType");
try {
versionableNodeType = ntMgr.getNodeType(versionableNodeTypeName);
if (versionableNodeType == null) {
fail("Property 'versionableNodeType' does not define a valid nodetype: '" + versionableNodeTypeName + "'");
}
} catch (NoSuchNodeTypeException e) {
fail("Property 'simpleVersionableNodeType' does not define an existing nodetype: '" + versionableNodeTypeName + "'");
}
// make sure 'non-versionable' nodetype is properly defined
try {
nonVersionableNodeType = ntMgr.getNodeType(testNodeType);
if (nonVersionableNodeType == null || nonVersionableNodeType.isNodeType(mixVersionable)) {
fail("Property 'testNodeType' does define a versionable nodetype: '" + testNodeType + "'");
}
} catch (NoSuchNodeTypeException e) {
fail("Property 'testNodeType' does not define an existing nodetype: '" + testNodeType + "'");
}
// build persistent versionable and non-versionable nodes
try {
versionableNode = createVersionableNode(testRootNode, nodeName1, versionableNodeType);
} catch (RepositoryException e) {
fail("Failed to create versionable test node." + e.getMessage());
}
try {
nonVersionableNode = testRootNode.addNode(nodeName3, nonVersionableNodeType.getName());
testRootNode.getSession().save();
} catch (RepositoryException e) {
fail("Failed to create non-versionable test node." + e.getMessage());
}
propertyValue = getProperty("propertyValue");
if (propertyValue == null) {
fail("Property 'propertyValue' is not defined.");
}
}
use of javax.jcr.nodetype.NoSuchNodeTypeException in project kylo by Teradata.
the class JcrExtensibleTypeProvider method deleteType.
@Override
public boolean deleteType(final ID id) {
final Session session = getSession();
final JcrExtensibleType.TypeId typeId = (JcrExtensibleType.TypeId) id;
try {
final Node typeNode = session.getNodeByIdentifier(typeId.getIdValue());
final String typeName = typeNode.getName();
session.getWorkspace().getNodeTypeManager().unregisterNodeType(typeName);
session.getRootNode().getNode(ExtensionsConstants.TYPES + "/" + typeName).remove();
return JcrExtensibleEntityProvider.cleanupDeletedType(session, typeName);
} catch (ItemNotFoundException | NoSuchNodeTypeException | NullPointerException e) {
// KYLO-8: Ignore NPE caused by unregistering a node type
return true;
} catch (UnsupportedRepositoryOperationException e) {
return false;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to retrieve extensible type: " + id, e);
}
}
use of javax.jcr.nodetype.NoSuchNodeTypeException in project jackrabbit-oak by apache.
the class ReadWriteNodeTypeManager method unregisterNodeTypes.
@Override
public void unregisterNodeTypes(String[] names) throws RepositoryException {
Root root = getWriteRoot();
Tree types = root.getTree(NODE_TYPES_PATH);
if (!types.exists()) {
throw new NoSuchNodeTypeException("Node types can not be unregistered.");
}
try {
for (String name : names) {
Tree type = types.getChild(getOakName(name));
if (!type.exists()) {
throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered.");
}
type.remove();
}
root.commit();
refresh();
} catch (CommitFailedException e) {
String message = "Failed to unregister node types.";
throw e.asRepositoryException(message);
}
}
use of javax.jcr.nodetype.NoSuchNodeTypeException in project jackrabbit-oak by apache.
the class MixinTest method testRemoveInheritedMixin2.
public void testRemoveInheritedMixin2() throws Exception {
try {
Authorizable user = ((JackrabbitSession) superuser).getUserManager().getAuthorizable("admin");
if (user == null) {
throw new NotExecutableException();
}
Node node = superuser.getNode(user.getPath());
assertTrue(node.isNodeType(JcrConstants.MIX_REFERENCEABLE));
node.removeMixin(JcrConstants.MIX_REFERENCEABLE);
} catch (NoSuchNodeTypeException e) {
// success
} finally {
superuser.refresh(false);
}
}
use of javax.jcr.nodetype.NoSuchNodeTypeException in project jackrabbit-oak by apache.
the class MixinTest method testRemoveMixinWithoutMixinProperty.
public void testRemoveMixinWithoutMixinProperty() throws Exception {
Node node = testRootNode.addNode("testRemoveMixinWithoutMixinProperty", NT_UNSTRUCTURED);
superuser.save();
try {
node.removeMixin(JcrConstants.MIX_REFERENCEABLE);
fail();
} catch (NoSuchNodeTypeException e) {
// success
} finally {
node.remove();
superuser.save();
}
}
Aggregations