Path repositoryPath = pathFactory.create(repositoriesPath, repositoryName);
Graph configuration = getConfigurationGraph();
Subgraph subgraph = configuration.getSubgraphOfDepth(6).at(repositoryPath);
// Read the options ...
Node optionsNode = subgraph.getNode(DnaLexicon.OPTIONS);
if (optionsNode != null) {
for (Location optionLocation : optionsNode.getChildren()) {
Node optionNode = configuration.getNodeAt(optionLocation);
Path.Segment segment = optionLocation.getPath().getLastSegment();
Property valueProperty = optionNode.getProperty(DnaLexicon.VALUE);
if (valueProperty == null) continue;
Option option = Option.findOption(segment.getName().getLocalName());
if (option == null) continue;
options.put(option, valueProperty.getFirstValue().toString());
}
}
// Read the namespaces ...
ExecutionContext context = getExecutionContext();
Node namespacesNode = subgraph.getNode(DnaLexicon.NAMESPACES);
if (namespacesNode != null) {
GraphNamespaceRegistry registry = new GraphNamespaceRegistry(configuration, namespacesNode.getLocation().getPath(),
DnaLexicon.NAMESPACE_URI);
context = context.with(registry);
}
// Get the name of the source ...
Property property = subgraph.getRoot().getProperty(DnaLexicon.SOURCE_NAME);
if (property == null || property.isEmpty()) {
String readableName = readable(DnaLexicon.SOURCE_NAME);
String readablePath = readable(subgraph.getLocation());
String msg = JcrI18n.propertyNotFoundOnNode.text(readableName, readablePath, configuration.getCurrentWorkspaceName());
throw new RepositoryException(msg);
}
String sourceName = context.getValueFactories().getStringFactory().create(property.getFirstValue());
// Create the repository ...
JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, descriptors, options);
// Register all the the node types ...
Node nodeTypesNode = subgraph.getNode(JcrLexicon.NODE_TYPES);
if (nodeTypesNode != null) {
repository.getRepositoryTypeManager().registerNodeTypes(subgraph, nodeTypesNode.getLocation());// throws exception
}
return repository;
}