use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit by apache.
the class AbstractWorkspaceReferenceableTest method setUp.
protected void setUp() throws Exception {
super.setUp();
// we assume referencing is supported by repository
NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
// assert that this repository supports references
try {
NodeType referenceableNt = ntMgr.getNodeType(mixReferenceable);
if (referenceableNt == null) {
throw new NotExecutableException("Repository does not support Referencing: mixin nodetype '" + mixReferenceable + "' is missing.");
}
} catch (NoSuchNodeTypeException e) {
throw new NotExecutableException("Repository does not support Referencing: mixin nodetype '" + mixReferenceable + "' is missing.");
}
}
use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit by apache.
the class AbstractWorkspaceVersionableTest method setUp.
protected void setUp() throws Exception {
super.setUp();
// we assume versioning is supported by repository
NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
// assert that this repository supports versioning
try {
NodeType versionableNt = ntMgr.getNodeType(mixVersionable);
if (versionableNt == null) {
throw new NotExecutableException("Repository does not support versioning: mixin nodetype '" + mixVersionable + "' is missing.");
}
} catch (NoSuchNodeTypeException e) {
throw new NotExecutableException("Repository does not support versioning: mixin nodetype '" + mixVersionable + "' is missing.");
}
}
use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit by apache.
the class MixinTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
NodeTypeManager manager = superuser.getWorkspace().getNodeTypeManager();
if (!manager.hasNodeType("test:mimeType")) {
String cnd = "<test='http://www.apache.org/jackrabbit/test'>\n" + "[test:mimeType] > mix:mimeType mixin";
Reader cndReader = new InputStreamReader(new ByteArrayInputStream(cnd.getBytes()));
CndImporter.registerNodeTypes(cndReader, superuser);
}
}
use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit by apache.
the class NodeSetPrimaryTypeTest method testSetAbstractAsPrimaryType.
/**
* Tests if <code>Node.setPrimaryType(String)</code> throws a
* <code>ConstraintViolationException</code> if the
* name of a mixin type is passed
*/
public void testSetAbstractAsPrimaryType() throws RepositoryException {
Session session = testRootNode.getSession();
NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
NodeTypeIterator nts = manager.getPrimaryNodeTypes();
while (nts.hasNext()) {
NodeType nt = nts.nextNodeType();
if (nt.isAbstract()) {
try {
Node node = testRootNode.addNode(nodeName1, testNodeType);
node.setPrimaryType(nt.getName());
fail("Node.setPrimaryType(String) must throw ConstraintViolationException if the specified node type name refers to an abstract node type.");
} catch (ConstraintViolationException e) {
// success
} finally {
// reset the changes.
session.refresh(false);
}
}
}
}
use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit by apache.
the class NodeSetPrimaryTypeTest method testAddNonExisting.
/**
* Tests if <code>Node.setPrimaryType(String)</code> throws a
* <code>NoSuchNodeTypeException</code> if the
* name of an existing node type is passed.
*/
public void testAddNonExisting() throws RepositoryException {
Session session = testRootNode.getSession();
NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
String nonExistingMixinName = "abc";
while (manager.hasNodeType(nonExistingMixinName)) {
nonExistingMixinName += "_";
}
Node node = testRootNode.addNode(nodeName1, testNodeType);
try {
node.setPrimaryType(nonExistingMixinName);
// ev. only detected upon save
superuser.save();
fail("Node.setPrimaryType(String) must throw a NoSuchNodeTypeException if no nodetype exists with the given name.");
} catch (NoSuchNodeTypeException e) {
// success
}
}
Aggregations