/** * Creates a node type state * * @param parent * @param ntDef * @return * @throws RepositoryException */ private VirtualNodeState createNodeTypeState(VirtualNodeState parent, QNodeTypeDefinition ntDef) throws RepositoryException { NodeId id = calculateStableId(ntDef.getName().toString()); VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), id, NameConstants.NT_NODETYPE); // add properties ntState.setPropertyValue(NameConstants.JCR_NODETYPENAME, InternalValue.create(ntDef.getName())); ntState.setPropertyValues( NameConstants.JCR_SUPERTYPES, PropertyType.NAME, InternalValue.create(ntDef.getSupertypes())); ntState.setPropertyValue(NameConstants.JCR_ISMIXIN, InternalValue.create(ntDef.isMixin())); ntState.setPropertyValue( NameConstants.JCR_HASORDERABLECHILDNODES, InternalValue.create(ntDef.hasOrderableChildNodes())); if (ntDef.getPrimaryItemName() != null) { ntState.setPropertyValue( NameConstants.JCR_PRIMARYITEMNAME, InternalValue.create(ntDef.getPrimaryItemName())); } // add property defs QPropertyDefinition[] propDefs = ntDef.getPropertyDefs(); for (int i = 0; i < propDefs.length; i++) { VirtualNodeState pdState = createPropertyDefState(ntState, propDefs[i], ntDef, i); ntState.addChildNodeEntry(NameConstants.JCR_PROPERTYDEFINITION, pdState.getNodeId()); // add as hard reference ntState.addStateReference(pdState); } // add child node defs QNodeDefinition[] cnDefs = ntDef.getChildNodeDefs(); for (int i = 0; i < cnDefs.length; i++) { VirtualNodeState cnState = createChildNodeDefState(ntState, cnDefs[i], ntDef, i); ntState.addChildNodeEntry(NameConstants.JCR_CHILDNODEDEFINITION, cnState.getNodeId()); // add as hard reference ntState.addStateReference(cnState); } return ntState; }
/** * {@inheritDoc} * * <p>currently we have no dynamic ones, we just recreate the entire nodetypes tree */ protected VirtualNodeState createRootNodeState() throws RepositoryException { VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId, NameConstants.REP_NODETYPES, null); Name[] ntNames = ntReg.getRegisteredNodeTypes(); for (int i = 0; i < ntNames.length; i++) { QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(ntNames[i]); VirtualNodeState ntState = createNodeTypeState(root, ntDef); root.addChildNodeEntry(ntNames[i], ntState.getNodeId()); // add as hard reference root.addStateReference(ntState); } return root; }