System.exit(-1);
return;
}
Session session = null;
JcrTools tools = new JcrTools();
try {
// Get the repository
repository = engine.getRepository(repositoryName);
// Create a session ...
session = repository.login("default");
// Create the '/files' node that is an 'nt:folder' ...
Node root = session.getRootNode();
Node filesNode = root.addNode("files", "nt:folder");
assert filesNode != null;
// Update a couple of files ...
tools.uploadFile(session, "/files/caution.png", getFile("caution.png"));
tools.uploadFile(session, "/files/sample1.mp3", getFile("sample1.mp3"));
tools.uploadFile(session, "/files/fixedWidthFile.txt", getFile("fixedWidthFile.txt"));
tools.uploadFile(session, "/files/JcrRepository.class", getFile("JcrRepository.clazz"));
// Save the session ...
session.save();
// Now look for the output. Note that sequencing may take a bit, so we'll cheat by just trying
// to find the node until we can find it, waiting a maximum amount of time before failing.
// The proper way is to either use events or not to expect the sequencers have finished.
Node png = findNodeAndWait(session, "/images/caution.png", 10, TimeUnit.SECONDS);
if (print) tools.printSubgraph(png);
Node sampleMp3 = findNodeAndWait(session, "/audio/sample1.mp3", 10, TimeUnit.SECONDS);
if (print) tools.printSubgraph(sampleMp3);
Node javaClass = findNodeAndWait(session, "/java/JcrRepository.class", 10, TimeUnit.SECONDS);
if (print) tools.printSubgraph(javaClass);
Node textFile = findNodeAndWait(session, "/text/fixedWidthFile.txt", 10, TimeUnit.SECONDS);
if (print) tools.printSubgraph(textFile);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) session.logout();