RepositoryConfiguration config = RepositoryConfiguration.read(url);
startRepository(config);
try {
// Use a session to load the contents ...
Session session = repository.login();
try {
registerNodeTypes(session, "cnd/fincayra.cnd");
registerNodeTypes(session, "cnd/magnolia.cnd");
registerNodeTypes(session, "cnd/notionalTypes.cnd");
registerNodeTypes(session, "cnd/cars.cnd");
registerNodeTypes(session, "cnd/validType.cnd");
InputStream stream = resourceStream("io/cars-system-view.xml");
try {
session.getWorkspace().importXML("/", stream, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
} catch (Throwable t) {
t.printStackTrace();
} finally {
stream.close();
}
// Create a branch that contains some same-name-siblings ...
Node other = session.getRootNode().addNode("Other", "nt:unstructured");
Node a = other.addNode("NodeA", "nt:unstructured");
a.addMixin("mix:referenceable");
a.setProperty("something", "value3 quick brown fox");
a.setProperty("somethingElse", "value2");
a.setProperty("propA", "value1");
Node other2 = other.addNode("NodeA", "nt:unstructured");
other2.addMixin("mix:referenceable");
other2.setProperty("something", "value2 quick brown cat wearing hat");
other2.setProperty("propB", "value1");
other2.setProperty("propC", "value2");
Node other3 = other.addNode("NodeA", "nt:unstructured");
other3.addMixin("mix:referenceable");
other3.setProperty("something", new String[] {"black dog", "white dog"});
other3.setProperty("propB", "value1");
other3.setProperty("propC", "value3");
Value[] refValues = new Value[2];
refValues[0] = session.getValueFactory().createValue(other2);
refValues[1] = session.getValueFactory().createValue(other3);
other3.setProperty("otherNode", a);
other3.setProperty("otherNodes", refValues);
Node c = other.addNode("NodeC", "notion:typed");
c.setProperty("notion:booleanProperty", true);
c.setProperty("notion:booleanProperty2", false);
c.setProperty("propD", "value4");
c.setProperty("propC", "value1");
c.setProperty("notion:singleReference", a);
c.setProperty("notion:multipleReferences", refValues);
Node b = session.getRootNode().addNode("NodeB", "nt:unstructured");
b.setProperty("myUrl", "http://www.acme.com/foo/bar");
b.setProperty("pathProperty", a.getPath());
session.save();
// // Initialize the nodes count
// initNodesCount();
//
// // Prime creating a first XPath query and SQL query ...
// session.getWorkspace().getQueryManager().createQuery("//element(*,nt:unstructured)", Query.XPATH);
// session.getWorkspace().getQueryManager().createQuery("SELECT * FROM [nt:base]", Query.JCR_SQL2);
} finally {
session.logout();
}
// Prime creating the schemata ...
// repository.nodeTypeManager().getRepositorySchemata();
} catch (RuntimeException e) {