use of org.apache.jackrabbit.oak.plugins.name.ReadOnlyNamespaceRegistry in project jackrabbit-oak by apache.
the class NamespacePrefixNodestoreChecker method createContext.
@Override
public Context createContext(NodeStore globalStore, MountInfoProvider mip) {
Root root = RootFactory.createReadOnlyRoot(globalStore.getRoot());
ReadOnlyNamespaceRegistry registry = new ReadOnlyNamespaceRegistry(root);
return new Context(registry.getPrefixes());
}
use of org.apache.jackrabbit.oak.plugins.name.ReadOnlyNamespaceRegistry in project jackrabbit-oak by apache.
the class NodeTypeRegistryTest method registerNodeType.
@Test
public void registerNodeType() throws Exception {
registerNodeType(root, "oak6440-1.cnd");
NodeTypeManager readOnlyNtMgr = new ReadOnlyNodeTypeManager() {
private Root r = session.getLatestRoot();
@Override
protected Tree getTypes() {
return r.getTree(NODE_TYPES_PATH);
}
};
NodeTypeManager ntMgr = new ReadWriteNodeTypeManager() {
@Override
protected Tree getTypes() {
return root.getTree(NODE_TYPES_PATH);
}
@Nonnull
@Override
protected Root getWriteRoot() {
return root;
}
};
ValueFactory valueFactory = new ValueFactoryImpl(root, new NamePathMapperImpl(new GlobalNameMapper(root)));
NamespaceRegistry nsRegistry = new ReadOnlyNamespaceRegistry(root);
DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory = new TemplateBuilderFactory(ntMgr, valueFactory, nsRegistry);
InputStream in = NodeTypeRegistryTest.class.getResourceAsStream("oak6440-2.cnd");
List<NodeTypeTemplate> templates;
try {
CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> reader = new CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry>(new InputStreamReader(in, UTF_8), "oak6440-2.cnd", factory);
templates = reader.getNodeTypeDefinitions();
} finally {
in.close();
}
for (NodeTypeTemplate t : templates) {
NodeTypeTemplateImpl template;
if (t instanceof NodeTypeTemplateImpl) {
template = (NodeTypeTemplateImpl) t;
} else {
template = new NodeTypeTemplateImpl(new GlobalNameMapper(root), t);
}
template.writeTo(root.getTree(NODE_TYPES_PATH), true);
}
NodeTypeDefinition beforeDef = readOnlyNtMgr.getNodeType("foo");
NodeTypeDefinition afterDef = ntMgr.getNodeType("foo");
NodeTypeDefDiff diff = NodeTypeDefDiff.create(beforeDef, afterDef);
assertFalse(diff.isMajor());
}
Aggregations