Implementing a document repository. Federation or File System connector?
napartar Jan 15, 2014 10:26 AMI'm just a beginner in Modeshape-JCR stuff. I did post a question for that at http://stackoverflow.com/questions/21017536/federating-the-file-system-results-in-child-not-found
I've seen JCR features around repository content, which allow to full-search, versioning and annotations, apart from other much benefits. Ok, let's say we want to develop a kind of CMS (a very simple one), which will mainly store Microsoft Office files. We're interested in having that directories naturally named in the File System, for the developer to be more intuitive to see what's going on without the need of starting the ModeShape engine. Apart from that, we will also like to have a repository which stands all of this, to provide our repository the features Modeshape-JCR allows.
Surfing into the web, I found a Modeshape Git repo which has some examples about how all of this works. I've also been looking though documentation for the last stable version (3.x branches). The examples show how to create a FS connector based repository (I think this want isn't what I need, since node names are taking hexadecimal values) and also to federate an existing File System. For my needs, I understand that federation is what I need, however Federation is defined by yourselves as a kind of ability to mix different connectors at the same repo, however I only want a repo which will persist the documents. So don't understand why I could not just use the FS connector!
Finally, I couldn't make federation example work out of the test case. The example is nice, but I would like to try it out with some absolute path. This is the test case I tried and already posted in StackOverflow:
{ "name" : "Test Repository", "jndiName" : "jcr/Test Repository", "monitoring" : { "enabled" : true }, "externalSources" : { "files" : { "classname" : "org.modeshape.connector.filesystem.FileSystemConnector", "directoryPath" : "C:/modeshape-repo", "projections" : [ "default:/files/ => /" ] } } }
@Test public void modeShapeFederating() throws LoginException, RepositoryException, IOException, URISyntaxException { File testDir = new File("C:/modeshape-repo"); Assert.assertTrue(testDir.exists() && testDir.isDirectory()); URL myTestURL = ClassLoader.getSystemResource("my_repository.json"); File configFile = new File(myTestURL.toURI()); Assert.assertTrue(configFile.exists()); ModeShapeEngine engine = new ModeShapeEngine(); engine.start(); RepositoryConfiguration config = RepositoryConfiguration .read(configFile); Repository repository = engine.deploy(config); System.out.println(engine.getState()); Session session = repository.login(); //Here is where the execution breaks try { Node filesNode = session.getRootNode().getNode("files"); Assert.assertTrue(filesNode.getNodes().getSize() > 0); } finally { session.logout(); } }
I would be very grateful if anybody can help me with this.
Yours, Aritz