Yamini Kumar
Posts: 1
Nickname: yamini1
Registered: Feb, 2008
|
|
Re: Catch Jackrabbit and the Java Content Repository API
|
Posted: Feb 25, 2008 1:46 AM
|
|
Hi, My objective is to standardize the access (read/write or both) to data content in data sources like a database (MySQL) and any other content repository that is not JSR 170 compliant like Open CMS, live link or share point. By standardizing access I mean that the client program will no longer call the respository specific API like LAPI or JDBC but rather call JCR API methods to achieve common functions like, login, logout, read and write.
I want to clear my concepts by writing a kind of sample connector for MY SQL database which can be accessed by JCR API rather than JDBC. I understand that in order to do I need to write a wrapper around JDBC API which will perform the desired operations using JDBC (as My SQL understand JDBC) but for a developer the entry point will be JCR API.
I have confusion while writing this wrapper. I have taken an example of exportsystemview() of JCR API.
The client code to access this method in CRX using JCR API is
/* public class ExportXMLFromCRX { public static void main(String[] args) { String propertyName = ""; Repository repository = null; Session repSession = null; FileInputStream fileInputStream = null; FileOutputStream fileOutputStream = null; try { ClientRepositoryFactory factory = new ClientRepositoryFactory(); // This is mandatory for rmi access to the CRX System.setProperty("java.rmi.server.useCodebaseOnly", "true"); repository = factory.getRepository("//localhost:1234/crx"); if(repository != null) { userCredentials = new SimpleCredentials(userID,password); repSession = repository.login(new SimpleCredentials(“admin”, “admin”.toCharArray(), “crx.default”); if(repSession != null) { File outputFile = new File("C:/test1.xml"); FileOutputStream out = new FileOutputStream(outputFile); repSession.exportSystemView("/MyRootNode", out, false, false); }//end if(repSession != null) }// end if(repository != null) } //end try catch (Exception Exc) { System.out.println(Exc.getMessage()); }//end catch finally { repSession.save(); //save to update nodes created in the CRX Session repSession.logout(); //duly log-out of the CRX session }//end try }// end finally } } */
What I want is to have a different implementation of the same method which will fetch data from database in an XML format & returns the XML the way the above method does
How should I write a wrapper class for my custom method which fetches record from DB and build an XML but exposed as JCR method? If I am able to do so then the above client code can be used as it is for my MYSQL wrapper code as well. The difference will be that it will no longer fetch data from CRX and build XML but will build an XML based on my database records.
Please suggest what are the steps I need to perform to achieve this?
|
|