@Override public NodeType[] getRequiredPrimaryTypes() { try { return new NodeType[] {ntManager.getNodeType(REP_ROOT)}; } catch (RepositoryException e) { return new NodeType[0]; } }
@Override public NodeType getDefaultPrimaryType() { try { return ntManager.getNodeType(REP_ROOT); } catch (RepositoryException e) { return null; } }
@Override public NodeType[] getRequiredPrimaryTypes() { try { return new NodeType[] {ntManager.getNodeType(REP_ROOT)}; } catch (RepositoryException e) { return new NodeType[0]; } }
public NodeType getDeclaringNodeType() { NodeType nodeType = null; try { nodeType = nodeTypeManager.getNodeType(declaringNT); } catch (RepositoryException e) { log.error("Error occurred while getting declared node type : " + declaringNT); } return nodeType; }
@Override public NodeType[] getMixinNodeTypes() throws RepositoryException { Value[] vals = this.node.getProperty("jcr:frozenMixinTypes").getValues(); NodeTypeManager typeMan = getJCRNode().getSession().getWorkspace().getNodeTypeManager(); NodeType[] types = new NodeType[vals.length]; int i = 0; for (Value val : vals) { types[i++] = typeMan.getNodeType(val.getString()); } return types; }
private NodeType getNodeType(Selector selector) throws RepositoryException { try { return ntManager.getNodeType(selector.getNodeTypeName()); } catch (NoSuchNodeTypeException e) { throw new InvalidQueryException( "Selected node type does not exist: " + selector, e); } }
private NodeType getNodeType(Selector selector) throws RepositoryException { try { return ntManager.getNodeType(selector.getNodeTypeName()); } catch (NoSuchNodeTypeException e) { throw new InvalidQueryException( "Selected node type does not exist: " + selector, e); } }
/** * Test if getNode() returns the name of a node type. */ public void testGetName() throws RepositoryException { NodeType type = manager.getNodeType(ntBase); assertEquals("getName() must return the name of the node", ntBase, type.getName()); }
private static NodeType getJcrNodeType(String superType) throws RepositoryException { try { return UserSession.get().getJcrSession().getWorkspace().getNodeTypeManager().getNodeType(superType); } catch (NoSuchNodeTypeException e) { if (log.isDebugEnabled()) { log.warn("Could not retrieve node type '" + superType + "'. Maybe it is not committed yet.", e); } else { log.warn("Could not retrieve node type '{}'. Maybe it is not committed yet. {}", superType, e.toString()); } } return null; }
private boolean allowsSNS(final String nodeType) throws RepositoryException { final NodeType nt = ntm.getNodeType(nodeType); for (final NodeDefinition nd : nt.getDeclaredChildNodeDefinitions()) { if (nd.allowsSameNameSiblings()) { return true; } } return false; }
/** * Get original node type. * * @return original node type if exists or null */ public NodeType getOriginalNodeType() throws RepositoryException { if (this.originalNodeType == null && getNodeTypeManager().hasNodeType(this.nodeType)) { this.originalNodeType = getNodeTypeManager().getNodeType(this.nodeType); } return this.originalNodeType; }
public static NodeType getNodeType(Session session, String typeName) { try { return session.getWorkspace().getNodeTypeManager().getNodeType(typeName); } catch (NoSuchNodeTypeException e) { throw new MetadataRepositoryException("No node type exits named: " + typeName, e); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to retrieve node type named: " + typeName, e); } }
@Test public void testDoExecute() throws RepositoryException, TaskExecutionException { // GIVEN RemoveMetaDataInNodeTypeDefinitionTask task = new RemoveMetaDataInNodeTypeDefinitionTask("name", "description", RepositoryConstants.CONFIG); // WHEN task.doExecute(installContext); // THEN checkIfMetaDataIsDefineAsChildNode(nodeTypeManager.getNodeType(NodeTypes.Content.NAME)); checkIfMetaDataIsDefineAsChildNode(nodeTypeManager.getNodeType(NodeTypes.ContentNode.NAME)); checkIfMetaDataIsDefineAsChildNode(nodeTypeManager.getNodeType(NodeTypes.Folder.NAME)); }
private boolean isAHippoResource(final IFieldValidator type) throws ValidationException { String jcrTypeName = type.getFieldType().getType(); try { Session jcrSession = UserSession.get().getJcrSession(); NodeTypeManager typeManager = jcrSession.getWorkspace().getNodeTypeManager(); NodeType nodeType = typeManager.getNodeType(jcrTypeName); return nodeType.isNodeType(HippoNodeType.NT_RESOURCE); } catch (RepositoryException e) { throw new ValidationException(e); } }
@Test public void verifyReplacedBuiltinNodeTypes() throws Exception { Session session = createAdminSession(); try { NodeTypeManager manager = session.getWorkspace().getNodeTypeManager(); NodeType nt = manager.getNodeType(UserConstants.NT_REP_GROUP); assertTrue("Migrated repository must have new nodetype definitions", nt.isNodeType(UserConstants.NT_REP_MEMBER_REFERENCES)); } finally { session.logout(); } }
@Test public void updateFrom549AddsLockableMixinToActivatableAndVersionable() throws Exception { // GIVEN NodeTypeManager nodeTypeManager = configSession.getWorkspace().getNodeTypeManager(); // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.4.9")); // THEN NodeType activatable = nodeTypeManager.getNodeType(NodeTypes.Activatable.NAME); NodeType versionable = nodeTypeManager.getNodeType(NodeTypes.Versionable.NAME); assertThat(containsAllSupertypes(activatable, Lists.newArrayList(JcrConstants.MIX_LOCKABLE)), is(true)); assertThat(containsAllSupertypes(versionable, Lists.newArrayList(JcrConstants.MIX_LOCKABLE)), is(true)); }
@Test public void addMgnlActivatableMixinForMgnlResource() throws RepositoryException, TaskExecutionException { // GIVEN AddActivatableMixinForMgnlResourceTask task = new AddActivatableMixinForMgnlResourceTask("name", "description", RepositoryConstants.WEBSITE); // WHEN task.execute(installContext); // THEN NodeType nt = nodeTypeManager.getNodeType(NodeTypes.Resource.NAME); assertThat(nt.getDeclaredSupertypes().length, is(4)); assertTrue(containsAllSupertypes(nt, Arrays.asList(JcrConstants.NT_RESOURCE, NodeTypes.Activatable.NAME, NodeTypes.Created.NAME, NodeTypes.LastModified.NAME))); } }
@Test public void addLockableMixinToVersionableMixin() throws Exception { // GIVEN AddLockableMixinToVersionableMixinTask task = new AddLockableMixinToVersionableMixinTask("", "", RepositoryConstants.WEBSITE); // WHEN task.execute(installContext); // THEN NodeType versionableNodeType = nodeTypeManager.getNodeType(NodeTypes.Versionable.NAME); assertThat(versionableNodeType.getDeclaredSupertypes(), arrayWithSize(1)); assertTrue(containsAllSupertypes(versionableNodeType, Arrays.asList(JcrConstants.MIX_LOCKABLE))); } }
@Test public void addLockableMixinToVersionableMixin() throws Exception { // GIVEN AddLockableMixinToActivatableMixinTask task = new AddLockableMixinToActivatableMixinTask("", "", RepositoryConstants.WEBSITE); // WHEN task.execute(installContext); // THEN NodeType activatableNodeType = nodeTypeManager.getNodeType(NodeTypes.Activatable.NAME); assertThat(activatableNodeType.getDeclaredSupertypes(), arrayWithSize(1)); assertTrue(containsAllSupertypes(activatableNodeType, Arrays.asList(JcrConstants.MIX_LOCKABLE))); } }
public static void checkNodeType(String nodeTypeName, List<String> superTypes, NodeTypeManager nodeTypeManager) throws NoSuchNodeTypeException, RepositoryException { NodeType nodeTypeContent = nodeTypeManager.getNodeType(nodeTypeName); assertNotNull(nodeTypeContent); assertEquals("Should have only one generic child", 1, nodeTypeContent.getDeclaredChildNodeDefinitions().length); assertEquals("*", nodeTypeContent.getDeclaredChildNodeDefinitions()[0].getName()); assertEquals(false, nodeTypeContent.getDeclaredChildNodeDefinitions()[0].allowsSameNameSiblings()); assertEquals("Should have " + superTypes.size() + " supertype defined", superTypes.size(), nodeTypeContent.getDeclaredSupertypeNames().length); assertEquals("Should have 2 propertyDefinition defined", 2, nodeTypeContent.getDeclaredPropertyDefinitions().length); assertTrue("Should have all supertype declared", containsAllSupertypes(nodeTypeContent, superTypes)); }