// Create the namespace registry and corresponding execution context.
// Note that this persistent registry has direct access to the system workspace.
Name uriProperty = DnaLexicon.NAMESPACE_URI;
PathFactory pathFactory = executionContext.getValueFactories().getPathFactory();
Path systemPath = pathFactory.create(JcrLexicon.SYSTEM);
Path namespacesPath = pathFactory.create(systemPath, DnaLexicon.NAMESPACES);
PropertyFactory propertyFactory = executionContext.getPropertyFactory();
Property namespaceType = propertyFactory.create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.NAMESPACE);
// Now create the registry implementation ...
this.persistentRegistry = new GraphNamespaceRegistry(systemGraph, namespacesPath, uriProperty, namespaceType);
this.executionContext = executionContext.with(persistentRegistry);
// Add the built-ins, ensuring we overwrite any badly-initialized values ...
for (Map.Entry<String, String> builtIn : JcrNamespaceRegistry.STANDARD_BUILT_IN_NAMESPACES_BY_PREFIX.entrySet()) {
this.persistentRegistry.register(builtIn.getKey(), builtIn.getValue());
}
// Set up the repository type manager ...
try {
this.repositoryTypeManager = new RepositoryNodeTypeManager(this.executionContext);
this.repositoryTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {
"/org/jboss/dna/jcr/jsr_170_builtins.cnd", "/org/jboss/dna/jcr/dna_builtins.cnd"}));
} catch (RepositoryException re) {
re.printStackTrace();
throw new IllegalStateException("Could not load node type definition files", re);
} catch (IOException ioe) {
ioe.printStackTrace();
throw new IllegalStateException("Could not access node type definition files", ioe);
}
if (Boolean.valueOf(this.options.get(Option.PROJECT_NODE_TYPES))) {
// Note that the node types are written directly to the system workspace.
Path parentOfTypeNodes = pathFactory.create(systemPath, JcrLexicon.NODE_TYPES);
this.repositoryTypeManager.projectOnto(systemGraph, parentOfTypeNodes);
}
// Create the projection for the system repository ...
ProjectionParser projectionParser = ProjectionParser.getInstance();