I am very new in Jack Rabbit repository.! So please guide me for fetching recent version of a file from Jackrabbit repository. My code is : try{
session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
Node root = session.getRootNode();
if (!root.hasNode(nodeName)) {
root.addNode(nodeName, "nt:unstructured");
session.save();
}
String extention = FilenameUtils.getExtension(originalFileName);
InputStream stream = new BufferedInputStream(new FileInputStream(file));
Node roseNode = session.getRootNode().getNode(nodeName);
VersionManager vm = session.getWorkspace().getVersionManager();
Node fileNode = null;
if(roseNode.hasNode(fileName.toString()+"."+extention)){
fileNode = roseNode.getNode(fileName.toString()+"."+extention);
vm.checkout(fileNode.getPath());
} else {
fileNode = roseNode.addNode(fileName.toString()+"."+extention, "nt:unstructured");
fileNode.addMixin("mix:versionable");
fileNode.setProperty(extention, fileName.toString());
session.save();
}
Node content = fileNode.addNode("jcr:content", "nt:resource");
Binary binary = session.getValueFactory().createBinary(stream);
content.setProperty("jcr:data", binary);
stream.close();
session.save();
vm.checkin(fileNode.getPath());
I tried this.. But I am getting the older file while fetching.. Please help me on this... Thanks in advance..