So, you're not happy with the present importers? You have got data in a format that is not covered by the current selection of importers? No problem, just build one yourself!
There are three steps to complete to write an importer.
Now this should be easy: Open the file, write a new enum with a different identifier and you are done. In case you want to extend an existing format (CSV comes to mind) to import something different than Contacts (which currently is the only use for it), you do not need to define a new format.
For the most current information, have a look the JavaDoc for the Importer Interface. Here are just two notes:
This method is called by the class which selects an appropriate importer. So make sure to use all your checking here, like
This methods does the import (you guessed that). I'd recommend that it internally calls canImport to be sure. The main job consists of writing the data into the folder. This usually is done by creating containing objects and writing them to the database. We got interfaces for that, of course:
com.openexchange.groupware.containerand end with *Object.
com.openexchange.api2and are named *SQLInterface for some strange reason.
As said, open the file
importerExporter.xml. After checking out the projects, this should be in the main project at
/conf/groupware, if installed, it ought to be somewhere like
The file looks like this, just go to the two comment lines and do like people before you did:
<beans> <bean id="importerExporter" class="com.openexchange.groupware.importexport.ImporterExporter"> <property name="importers"> <list> <ref bean="iCalImporter" /> <ref bean="vCardImporter" /> <ref bean="csvContactImporter" /> <!-- add reference to your class here --> </list> </property> </bean> <bean id="iCalImporter" class="com.openexchange.groupware.importexport.importers.ICalImporter" /> <bean id="vCardImporter" class="com.openexchange.groupware.importexport.importers.VCardImporter" /> <bean id="csvContactImporter" class="com.openexchange.groupware.importexport.importers.CSVContactImporter" /> <!-- add your class here --> </beans>
Yep, this is Spring . Now you know what you need those
spring-beans.jar thingies for.