@Override public NodeTypeIterator getMixinNodeTypes() throws RepositoryException { return delegate.getMixinNodeTypes(); }
/** * @return a string that is not the name of a mixin type */ public static String getNonExistingMixinName(Session session) throws RepositoryException { NodeTypeManager manager = session.getWorkspace().getNodeTypeManager(); NodeTypeIterator mixins = manager.getMixinNodeTypes(); StringBuffer s = new StringBuffer("X"); while (mixins.hasNext()) { s.append(mixins.nextNodeType().getName()); } return s.toString().replaceAll(":", ""); }
/** {@inheritDoc} */ public RemoteIterator getMixinNodeTypes() throws RepositoryException, RemoteException { try { return getFactory().getRemoteNodeTypeIterator( manager.getMixinNodeTypes()); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
private List<String> getAllNodeTypes() { List<String> list = new ArrayList<String>(); try { UserSession session = (UserSession) getSession(); NodeTypeManager ntmgr = session.getJcrSession().getWorkspace().getNodeTypeManager(); NodeTypeIterator iterator = ntmgr.getMixinNodeTypes(); while (iterator.hasNext()) { list.add(iterator.nextNodeType().getName()); } } catch (RepositoryException e) { log.error(e.getMessage()); } Collections.sort(list); return list; }
public static String getNotAssignedMixinName(Session session, Node node) throws RepositoryException { NodeTypeManager manager = session.getWorkspace().getNodeTypeManager(); NodeTypeIterator mixins = manager.getMixinNodeTypes(); Set<String> existingMixins = new HashSet<String>(); for (NodeType nt : node.getMixinNodeTypes()) { existingMixins.add(nt.getName()); } while (mixins.hasNext()) { String ntName = mixins.nextNodeType().getName(); if (!existingMixins.contains(ntName)) { return ntName; } } return null; }
private List<String> getAllNodeTypes() { final List<String> result = new ArrayList<>(); try { final Session session = UserSession.get().getJcrSession(); final NodeTypeManager ntmgr = session.getWorkspace().getNodeTypeManager(); final NodeTypeIterator iterator = ntmgr.getMixinNodeTypes(); while (iterator.hasNext()) { result.add(iterator.nextNodeType().getName()); } } catch (RepositoryException e) { log.error(e.getMessage()); } Collections.sort(result); return result; }
/** * Tests if addNode() throws a ConstraintViolationException in case * of an mixin node type. */ public void testMixinNodeType() throws RepositoryException, NotExecutableException { NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager(); NodeTypeIterator nts = ntMgr.getMixinNodeTypes(); if (nts.hasNext()) { try { testRootNode.addNode(nodeName1, nts.nextNodeType().getName()); superuser.save(); fail("Expected ConstraintViolationException."); } catch (ConstraintViolationException e) { // correct. } } else { throw new NotExecutableException("no mixins."); } }
/** * Test if getMixinNodeTypes does return exclusively mixin node types */ public void testGetMixinNodeTypes() throws RepositoryException { NodeTypeIterator types = manager.getMixinNodeTypes(); while (types.hasNext()) { assertTrue("getMixinNodeTypes() must return exclusively mixin " + "node types", types.nextNodeType().isMixin()); } }
/** * Tests if <code>Node.setPrimaryType(String)</code> throws a * <code>ConstraintViolationException</code> if the * name of a mixin type is passed */ public void testSetMixinAsPrimaryType() throws RepositoryException { Session session = testRootNode.getSession(); NodeTypeManager manager = session.getWorkspace().getNodeTypeManager(); NodeTypeIterator nts = manager.getMixinNodeTypes(); while (nts.hasNext()) { try { Node node = testRootNode.addNode(nodeName1, testNodeType); node.setPrimaryType(nts.nextNodeType().getName()); fail("Node.setPrimaryType(String) must throw ConstraintViolationException if the specified node type name refers to a mixin."); } catch (ConstraintViolationException e) { // success } finally { // reset the changes. session.refresh(false); } } }
/** * @return the name of a mixin node type that can be added by the requested * <code>node</code> */ public static String getAddableMixinName(Session session, Node node) throws RepositoryException { NodeTypeManager manager = session.getWorkspace().getNodeTypeManager(); NodeTypeIterator mixins = manager.getMixinNodeTypes(); // Skip mix:shareable since not supported by removeMixin String mixShareable = session.getNamespacePrefix(AbstractJCRTest.NS_MIX_URI) + ":shareable"; while (mixins.hasNext()) { String name = mixins.nextNodeType().getName(); if (node.canAddMixin(name) && !node.isNodeType(name) && !mixShareable.equals(name)) { return name; } } return null; }
/** * Test if isMixin() returns false if applied on a primary node type and true * on a mixin node type. */ public void testIsMixin() throws RepositoryException { NodeTypeIterator primaryTypes = manager.getPrimaryNodeTypes(); assertFalse("testIsMixin() must return false if applied on a " + "primary node type", primaryTypes.nextNodeType().isMixin()); // if a mixin node type exist, test if isMixin() returns true NodeTypeIterator mixinTypes = manager.getMixinNodeTypes(); if (getSize(mixinTypes) > 0) { // need to re-aquire iterator {@link #getSize} may consume iterator mixinTypes = manager.getMixinNodeTypes(); assertTrue("testIsMixin() must return true if applied on a " + "mixin node type", mixinTypes.nextNodeType().isMixin()); } // else skip the test for mixin node types }
try { ntmgr = workspace.getNodeTypeManager(); types = ntmgr.getMixinNodeTypes(); } catch (RepositoryException e) { fail("Cannot access NodeType iterator: " + e);
/** * Test if getAllNodeTypes() returns all primary and mixin node types */ public void testGetAllNodeTypes() throws RepositoryException { long sizeAll = getSize(manager.getAllNodeTypes()); long sizePrimary = getSize(manager.getPrimaryNodeTypes()); long sizeMixin = getSize(manager.getMixinNodeTypes()); assertEquals("sizeAll() must return all primary and mixin node types:", sizePrimary + sizeMixin, sizeAll); }
@Override protected void setUp() throws Exception { super.setUp(); Reader cnd = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES)); CndImporter.registerNodeTypes(cnd, superuser); cnd.close(); NodeTypeIterator it = superuser.getWorkspace().getNodeTypeManager().getMixinNodeTypes(); while (it.hasNext()) { NodeType nt = it.nextNodeType(); if (nt.getName().startsWith("test:")) { testMixins.add(nt.getName()); } } testNode = testRootNode.addNode(nodeName1, "nt:unstructured"); superuser.save(); sessionB = getHelper().getSuperuserSession(); testNodeB = sessionB.getNode(testNode.getPath()); }
return ntMgr.getAllNodeTypes(); } else if (info.containsContentElement(XML_REPORT_MIXINNODETYPES, ItemResourceConstants.NAMESPACE)) { return ntMgr.getMixinNodeTypes(); } else if (info.containsContentElement(XML_REPORT_PRIMARYNODETYPES, ItemResourceConstants.NAMESPACE)) { return ntMgr.getPrimaryNodeTypes();
getMixinNodeTypes(); addAll(mixinNodeTypes).build())). when(nodeTypeManager). getMixinNodeTypes();
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code> * returns false if <code>nodeTypeName</code> represents a mixin. */ public void testCanAddMixinType() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false); if (nodeDef == null) { throw new NotExecutableException("No testable node type found."); } NodeType nodeType = nodeDef.getDeclaringNodeType(); String childNodeName = nodeDef.getName(); String mixinName; NodeTypeIterator it = manager.getMixinNodeTypes(); if (it.hasNext()) { mixinName = it.nextNodeType().getName(); } else { throw new NotExecutableException("No mixin type found."); } assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return false if nodeTypeName represents a mixin type.", nodeType.canAddChildNode(childNodeName, mixinName)); }