Error creating content using FileSystemSource
nlugert Feb 24, 2010 11:58 AMI am getting an error while attempting to add a new file via the Graph API.
Using 1.0 Beta with Java6
Here is my code:
Graph graph = client.getEngine().getGraph("CSP");
// Create the file node ...
graph.create("/modeshape.txt").with("jcr:primaryType","nt:file").and();
// Create the file's content node ...
Binary bin = context.getValueFactories().getBinaryFactory().create(new File("/usr/local/sandbox/Desktop/modeshape.txt"));
try {
bin.acquire();
graph.create("/modeshape.txt/jcr:content").with("jcr:primaryType","nt:resource").and("jcr:data",bin).and();
} finally {
bin.release();
}
I also tried this way and got the same error:
Graph graph = client.getEngine().getGraph("CSP");
graph.batch()
.create("/modeshape.txt").with("jcr:primaryType","nt:file")
.and()
.create("/modeshape.txt/jcr:content").with("jcr:primaryType","nt:resource").and("jcr:data",bin)
.and();
Here is the Error:
org.modeshape.graph.request.InvalidRequestException: Repository source "CSP" does not allow same name siblings on nodes: jcr:content
at org.modeshape.connector.filesystem.FileSystemRepository$FileSystemWorkspace.createNode(FileSystemRepository.java:289)
at org.modeshape.graph.connector.path.PathRequestProcessor.process(PathRequestProcessor.java:283)
at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:227)
at org.modeshape.graph.connector.path.PathRepositoryConnection.execute(PathRepositoryConnection.java:84)
at org.modeshape.graph.connector.RepositoryConnectionPool$ConnectionWrapper.execute(RepositoryConnectionPool.java:996)
at org.modeshape.graph.Graph.execute(Graph.java:267)
at org.modeshape.graph.Graph$5.process(Graph.java:210)
at org.modeshape.graph.request.RequestBuilder.createNode(RequestBuilder.java:289)
at org.modeshape.graph.Graph$12.submit(Graph.java:1300)
at org.modeshape.graph.Graph$12.submit(Graph.java:1293)
at org.modeshape.graph.Graph$CreateAction.and(Graph.java:7703)