Quickstart Guide

If you are familiar with Spring it is really easy. If not, there will be some kind of magic for you. But that dosen't matter, if you just use the higher API.

This guide just describes how you can use the higher API with the beans of this client library. If you want to map your own objects, please have a look at the mapping guide.

For a quick start please try the SimpleExample.java. Here is the documented and important source code of this class.

        //first we create the spring application context
        final String appContextFile =
                "classpath:net/sf/oxclient/spring/applicationContext.xml";
        final ApplicationContext ac =
                new ClassPathXmlApplicationContext(appContextFile);
        
        //Obtain the sessionFactory from the application context
        final IOXSessionFactory sessionFactory =
                (IOXSessionFactory) ac.getBean("oxSessionFactory");
        
        sessionFactory.setServerURL(serverUrl);
        
        //create the user to login
        final SimpleUser user = new SimpleUser();
        user.setLogin(userlogin);
        user.setPassword(pwd);
        
        //login and get the session
        final IOXSession session = sessionFactory.login(user);
        System.out.println(session.getSessionId());
        
        //get a list of root folders and the folder module
        final List<Folder> rootFolders = session.getRootFolders();
        final IFolderModule<Folder> folderModule = session.getFolderModule();
        
        //walk through the root folders and their child folders
        for (final Folder folder : rootFolders) {
                System.out.println(folder);
                System.out.println("-----------------------------------");
                final List<Folder> childes = folderModule.getSubFolders(folder);
                for (final Folder folder2 : childes) {
                        System.out.println(folder2);
                }
        }
        
        //get the contact module
        final IOXContactModule contactModule = session.getContactModule();
        
        //get the default folder for contacts of the user
        final Folder contactFolder = contactModule.getDefaultFolder();
        System.out.println(contactFolder);
        
        //walk through the contacts of the user
        final List<Contact> contacts = contactModule.list(contactFolder);
        for (Contact contact : contacts) {
                System.out.println(contact);
        }