/** * 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(); }
/** * Registers the node types defined in the given input stream depending * on the content type specified for the stream. This will also register * any namespaces identified in the input stream if they have not already * been registered. * * {@inheritDoc} */ public NodeType[] registerNodeTypes(InputStream in, String contentType) throws IOException, RepositoryException { return registerNodeTypes(in, contentType, false); }
/** * {@inheritDoc} */ public NodeType[] getSupertypes() { Name[] ntNames = ent.getInheritedNodeTypes(); NodeType[] supertypes = new NodeType[ntNames.length]; for (int i = 0; i < ntNames.length; i++) { try { supertypes[i] = ntMgr.getNodeType(ntNames[i]); } catch (NoSuchNodeTypeException e) { // should never get here log.error("undefined supertype", e); return new NodeType[0]; } } return supertypes; }
/** * 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); } }
NodeType nt = ntMgr.getNodeType(ntName); if (nt.isMixin()) { throw new ConstraintViolationException(nodeTypeName + ": not a primary node type."); NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entNew, entOld, entAll; try { if (def.isAutoCreated()) { if (def.definesNode()) { NodeDefinitionImpl ndi = ntMgr.getNodeDefinition((QNodeDefinition) def); createChildNode(def.getName(), (NodeTypeImpl) ndi.getDefaultPrimaryType(), null); } else { PropertyDefinitionImpl pdi = ntMgr.getPropertyDefinition((QPropertyDefinition) def); createChildProperty(pdi.unwrap().getName(), pdi.getRequiredType(), pdi);
NodeTypeImpl mixin = ntMgr.getNodeType(ntName); if (!mixin.isMixin()) { return false; NodeTypeImpl primaryType = ntMgr.getNodeType(primaryTypeName); if (primaryType.isDerivedFrom(ntName)) { NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entExisting; try {
for (NodeTypeDefinition definition : definitions) { QNodeTypeDefinition def = toNodeTypeDef(definition); if (registry.isRegistered(def.getName())) { if (allowUpdate) { result.addAll(registerNodeTypes(addedDefs)); result.add(getNodeType(nodeTypeDef.getName()));
nodeTypes.addAll(registerNodeTypes(newNodeTypeDefs)); nodeTypes.add(getNodeType(nodeTypeDef.getName())); Collection<NodeType> types = registerNodeTypes(nodeTypeDefs); return types.toArray(new NodeType[types.size()]);
/** * Creates a component context for the given session. * * @param repositoryContext repository context of the session * @param session the session * @param workspaceConfig workspace configuration * @throws RepositoryException if the workspace can not be accessed */ public SessionContext( RepositoryContext repositoryContext, SessionImpl session, WorkspaceConfig workspaceConfig) throws RepositoryException { assert repositoryContext != null; assert session != null; this.repositoryContext = repositoryContext; this.session = session; this.state = new SessionState(this); this.valueFactory = new ValueFactoryImpl(session, repositoryContext.getDataStore()); this.itemValidator = new ItemValidator(this); this.nodeTypeManager = new NodeTypeManagerImpl(this); this.privilegeManager = new PrivilegeManagerImpl(repositoryContext.getPrivilegeRegistry(), session); this.nsRegistry = new PermissionAwareNamespaceRegistry(); this.workspace = new WorkspaceImpl(this, workspaceConfig); }
context.getNodeTypeManager().dispose();
NamePathResolver namePathResolver = ((NodeTypeManagerImpl) nodeTypeManager).getNamePathResolver();
for (String name : mixinNames) { Name qName = sessionContext.getQName(name); if (! ntMgr.getNodeType(qName).isMixin()) { throw new RepositoryException( sessionContext.getJCRName(qName) + " is not a mixin node type"); NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entNew, entOld, entAll; try { if (def.isAutoCreated()) { if (def.definesNode()) { NodeDefinitionImpl ndi = ntMgr.getNodeDefinition((QNodeDefinition) def); createChildNode(def.getName(), (NodeTypeImpl) ndi.getDefaultPrimaryType(), null); } else { PropertyDefinitionImpl pdi = ntMgr.getPropertyDefinition((QPropertyDefinition) def); createChildProperty(pdi.unwrap().getName(), pdi.getRequiredType(), pdi);
NodeTypeImpl mixin = ntMgr.getNodeType(ntName); if (!mixin.isMixin()) { return false; NodeTypeImpl primaryType = ntMgr.getNodeType(primaryTypeName); if (primaryType.isDerivedFrom(ntName)) { NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entExisting; try {
for (NodeTypeDefinition definition : definitions) { QNodeTypeDefinition def = toNodeTypeDef(definition); if (registry.isRegistered(def.getName())) { if (allowUpdate) { result.addAll(registerNodeTypes(addedDefs)); result.add(getNodeType(nodeTypeDef.getName()));
nodeTypes.addAll(registerNodeTypes(newNodeTypeDefs)); nodeTypes.add(getNodeType(nodeTypeDef.getName())); Collection<NodeType> types = registerNodeTypes(nodeTypeDefs); return types.toArray(new NodeType[types.size()]);
/** * Creates a component context for the given session. * * @param repositoryContext repository context of the session * @param session the session * @param workspaceConfig workspace configuration * @throws RepositoryException if the workspace can not be accessed */ public SessionContext( RepositoryContext repositoryContext, SessionImpl session, WorkspaceConfig workspaceConfig) throws RepositoryException { assert repositoryContext != null; assert session != null; this.repositoryContext = repositoryContext; this.session = session; this.state = new SessionState(this); this.valueFactory = new ValueFactoryImpl(session, repositoryContext.getDataStore()); this.itemValidator = new ItemValidator(this); this.nodeTypeManager = new NodeTypeManagerImpl(this); this.privilegeManager = new PrivilegeManagerImpl(repositoryContext.getPrivilegeRegistry(), session); this.nsRegistry = new PermissionAwareNamespaceRegistry(); this.workspace = new WorkspaceImpl(this, workspaceConfig); }
context.getNodeTypeManager().dispose();
/** * 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(); }
for (String name : mixinNames) { Name qName = sessionContext.getQName(name); if (! ntMgr.getNodeType(qName).isMixin()) { throw new RepositoryException( sessionContext.getJCRName(qName) + " is not a mixin node type"); NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry(); EffectiveNodeType entNew, entOld, entAll; try { if (def.isAutoCreated()) { if (def.definesNode()) { NodeDefinitionImpl ndi = ntMgr.getNodeDefinition((QNodeDefinition) def); createChildNode(def.getName(), (NodeTypeImpl) ndi.getDefaultPrimaryType(), null); } else { PropertyDefinitionImpl pdi = ntMgr.getPropertyDefinition((QPropertyDefinition) def); createChildProperty(pdi.unwrap().getName(), pdi.getRequiredType(), pdi);
/** * {@inheritDoc} */ public NodeType[] getSupertypes() { Name[] ntNames = ent.getInheritedNodeTypes(); NodeType[] supertypes = new NodeType[ntNames.length]; for (int i = 0; i < ntNames.length; i++) { try { supertypes[i] = ntMgr.getNodeType(ntNames[i]); } catch (NoSuchNodeTypeException e) { // should never get here log.error("undefined supertype", e); return new NodeType[0]; } } return supertypes; }