/** * Creates a new version manager base for the given session * * @param context component context of the current session * @param stateMgr the underlying state manager * @param hierMgr local hierarchy manager */ protected VersionManagerImplBase( SessionContext context, UpdatableItemStateManager stateMgr, HierarchyManager hierMgr) { this.context = context; this.session = context.getSessionImpl(); this.stateMgr = stateMgr; this.hierMgr = hierMgr; this.ntReg = session.getNodeTypeManager().getNodeTypeRegistry(); this.vMgr = session.getInternalVersionManager(); }
/** * {@inheritDoc} */ public boolean canAddChildNode(String childNodeName, String nodeTypeName) { try { ent.checkAddNodeConstraints( resolver.getQName(childNodeName), resolver.getQName(nodeTypeName), ntMgr.getNodeTypeRegistry()); return true; } catch (NameException be) { // implementation specific exception, fall through } catch (RepositoryException re) { // fall through } return false; }
/** * {@inheritDoc} */ public boolean canAddChildNode(String childNodeName, String nodeTypeName) { try { ent.checkAddNodeConstraints( resolver.getQName(childNodeName), resolver.getQName(nodeTypeName), ntMgr.getNodeTypeRegistry()); return true; } catch (NameException be) { // implementation specific exception, fall through } catch (RepositoryException re) { // fall through } return false; }
/** * Creates a new version manager base for the given session * * @param context component context of the current session * @param stateMgr the underlying state manager * @param hierMgr local hierarchy manager */ protected VersionManagerImplBase( SessionContext context, UpdatableItemStateManager stateMgr, HierarchyManager hierMgr) { this.context = context; this.session = context.getSessionImpl(); this.stateMgr = stateMgr; this.hierMgr = hierMgr; this.ntReg = session.getNodeTypeManager().getNodeTypeRegistry(); this.vMgr = session.getInternalVersionManager(); }
/** * Checks whether a node type with the given name exists. * * @param name node type name * @return <code>true</code> if the named node type exists, * <code>false</code> otherwise * @throws RepositoryException if the name format is invalid */ public boolean hasNodeType(String name) throws RepositoryException { try { Name qname = context.getQName(name); return getNodeTypeRegistry().isRegistered(qname); } catch (NamespaceException e) { return false; } catch (NameException e) { throw new RepositoryException("Invalid name: " + name, e); } }
/** * Checks whether a node type with the given name exists. * * @param name node type name * @return <code>true</code> if the named node type exists, * <code>false</code> otherwise * @throws RepositoryException if the name format is invalid */ public boolean hasNodeType(String name) throws RepositoryException { try { Name qname = context.getQName(name); return getNodeTypeRegistry().isRegistered(qname); } catch (NamespaceException e) { return false; } catch (NameException e) { throw new RepositoryException("Invalid name: " + name, e); } }
/** * As Jackrabbit {@link NodeTypeRegistry#unregisterNodeTypes} doesn't cover more * than one level of dependencies, we need to manually get all dependencies recursively. The ones we find are added * to a list in order to register them afterwards. */ private void getDependencies(NodeTypeManager nodeTypeManager, String nodeTypeName, List<NodeTypeDefinition> dependentNodeTypeDefinitions) throws RepositoryException { NodeTypeRegistry registry = ((NodeTypeManagerImpl) nodeTypeManager).getNodeTypeRegistry(); NamePathResolver namePathResolver = ((NodeTypeManagerImpl) nodeTypeManager).getNamePathResolver(); Set<Name> directChildNodeTypeQNames = registry.getDependentNodeTypes(namePathResolver.getQName(nodeTypeName)); if (directChildNodeTypeQNames.size() == 0) { return; } for (Name directChildNodeTypeQName : directChildNodeTypeQNames) { dependentNodeTypeDefinitions.add(((NodeTypeManagerImpl) nodeTypeManager).getNodeType(directChildNodeTypeQName)); getDependencies(nodeTypeManager, namePathResolver.getJCRName(directChildNodeTypeQName), dependentNodeTypeDefinitions); } }
NodeTypeRegistry ntReg; try { ntReg = ((NodeTypeManagerImpl) ntMgr).getNodeTypeRegistry(); } catch (ClassCastException e) {
getNodeTypeRegistry().unregisterNodeTypes(ntNames);
getNodeTypeRegistry().unregisterNodeTypes(ntNames);
public static void initializeNodetypes(Session session, InputStream cndStream, String cndName) throws RepositoryException { try { log.debug("Initializing nodetypes from {} ", cndName); final NamespaceRegistry namespaceRegistry = session.getWorkspace().getNamespaceRegistry(); final CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> cndReader = new HippoCompactNodeTypeDefReader(new InputStreamReader(cndStream), cndName, namespaceRegistry); final List<QNodeTypeDefinition> ntdList = cndReader.getNodeTypeDefinitions(); final NodeTypeRegistry nodeTypeRegistry = ((NodeTypeManagerImpl) session.getWorkspace().getNodeTypeManager()).getNodeTypeRegistry(); for (QNodeTypeDefinition ntd : ntdList) { try { if (!nodeTypeRegistry.isRegistered(ntd.getName())) { log.debug("Registering node type {}", ntd.getName()); nodeTypeRegistry.registerNodeType(ntd); } else { log.debug("Replacing node type {}", ntd.getName()); nodeTypeRegistry.reregisterNodeType(ntd); } } catch (InvalidNodeTypeDefException e) { throw new RepositoryException("Invalid node type definition for node type " + ntd.getName(), e); } } } catch (ParseException e) { throw new RepositoryException("Failed to parse cnd " + cndName, e); } }
List ntdList = remap.cndReader.getNodeTypeDefinitions(); NodeTypeManagerImpl ntmgr = (NodeTypeManagerImpl)workspace.getNodeTypeManager(); NodeTypeRegistry ntreg = ntmgr.getNodeTypeRegistry(); for (Iterator<QNodeTypeDefinition> iter = ntdList.iterator(); iter.hasNext();) { QNodeTypeDefinition ntd = (QNodeTypeDefinition)iter.next();
protected void setUp() throws Exception { isReadOnly = true; super.setUp(); InputStream xml = getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES); QNodeTypeDefinition[] ntDefs = NodeTypeReader.read(xml); NodeTypeRegistry ntReg = ((SessionImpl) superuser).getNodeTypeManager().getNodeTypeRegistry(); if (!ntReg.isRegistered(ntDefs[0].getName())) { ntReg.registerNodeTypes(Arrays.asList(ntDefs)); } }
NodeTypeRegistry registry = ((NodeTypeManagerImpl) getNodeTypeManager()).getNodeTypeRegistry(); registry.disableCheckForReferencesInContentException = true; log.info("Unregistering [{}] node type.", nodeType);
/** * Sets up the fixture for the test cases. */ protected void setUp() throws Exception { //isReadOnly = true; super.setUp(); session = getHelper().getReadOnlySession(); manager = session.getWorkspace().getNodeTypeManager(); nameFactory = NameFactoryImpl.getInstance(); // Get the NodeTypeManager from the Workspace. // Note that it must be cast from the generic JCR NodeTypeManager to the // Jackrabbit-specific implementation. NodeTypeManagerImpl ntmgr = (NodeTypeManagerImpl) session.getWorkspace().getNodeTypeManager(); // Acquire the NodeTypeRegistry ntreg = ntmgr.getNodeTypeRegistry(); }
NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entExisting; try {
private void importTestNodeTypes() throws IOException, InvalidNodeTypeDefException, RepositoryException { // import some test node types that contain a node def with sameNameSiblings="false" InputStream xml = getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES); QNodeTypeDefinition[] ntDefs = NodeTypeReader.read(xml); NodeTypeRegistry ntReg = ((SessionImpl) superuser).getNodeTypeManager().getNodeTypeRegistry(); if (!ntReg.isRegistered(ntDefs[0].getName())) { ntReg.registerNodeTypes(Arrays.asList(ntDefs)); } // make sure the node def is there as required for our test NodeTypeManager ntm = superuser.getWorkspace().getNodeTypeManager(); NodeType nodeType = ntm.getNodeType("test:childNodeType"); NodeDefinition[] childNodeDefinitions = nodeType.getChildNodeDefinitions(); boolean foundRequiredDef = false; for (NodeDefinition nodeDefinition : childNodeDefinitions) { String nodeDefName = nodeDefinition.getName(); if (nodeDefName.equals("test:defaultTypeNode") && !nodeDefinition.allowsSameNameSiblings()) { foundRequiredDef = true; break; } } assertTrue(TEST_NODETYPES + " has changed? Expected child node def 'test:defaultTypeNode' with sameNameSiblings=false", foundRequiredDef); } }
NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entExisting; try {
NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry(); NodeTypeManager ntmgr = workspace.getNodeTypeManager(); NodeTypeRegistry nodetypeRegistry = ((NodeTypeManagerImpl)ntmgr).getNodeTypeRegistry(); try { namespaceRegistry.registerNamespace(NAMESPACE_PREFIX, NAMESPACE_URI);
NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entNew, entOld, entAll; try {