Jwma

dtw.webmail.plugin.std
Class CastorSQLContactManagement

java.lang.Object
  |
  +--dtw.webmail.plugin.std.CastorSQLContactManagement
All Implemented Interfaces:
ContactManagementPlugin, JwmaPlugin

public class CastorSQLContactManagement
extends java.lang.Object
implements ContactManagementPlugin

A ContactManagementPlugin implementation based on Castor JDO.

Stores the contacts in a database.

Version:
0.9.7 07/02/2003
Author:
Dieter Wimberger

Field Summary
static java.lang.String TYPE_VCARD2
           
static java.lang.String TYPE_VCARD3
           
 
Fields inherited from interface dtw.webmail.plugin.ContactManagementPlugin
CONTACT_EXPORT, CONTACT_IMPORT, DATABASE_EXPORT, DATABASE_IMPORT
 
Constructor Summary
CastorSQLContactManagement()
           
 
Method Summary
 void activate()
          Activates the plugin for subsequent use.
 JwmaContactsImpl createContacts()
          Creates a new contact databse instance.
 void deactivate()
          Deactivates the plugin.
 java.lang.String exportContact(JwmaContact contact, java.lang.String TYPE)
          Exports a contact in the given type.
 void exportDatabase(java.io.OutputStream out, JwmaContacts db, java.lang.String TYPE)
          Exports the given contact database in the given type.
 java.lang.String[] getSupportedTypes(int IMEX_TYPE)
          Returns a list of types for the given import/export method.
 JwmaContact importContact(java.io.InputStream in, java.lang.String TYPE)
          Imports a contact of the given type.
 JwmaContact[] importDatabase(java.io.InputStream in, java.lang.String TYPE)
          Imports a database of contacts of the given type.
 boolean isPersistent(java.lang.String cuid)
          Tests if a given contact database exists on the store.
 boolean isSupportedContactImportType(java.lang.String type)
          Tests if the given contact type can be imported.
 JwmaContactsImpl loadContacts(java.lang.String cuid)
          Loads the given contacts database from the persistent store and returns them as a JwmaContactsImpl instance.
 void saveContacts(JwmaContactsImpl contacts)
          Saves the given contacts database to the persistent store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_VCARD3

public static final java.lang.String TYPE_VCARD3
See Also:
Constant Field Values

TYPE_VCARD2

public static final java.lang.String TYPE_VCARD2
See Also:
Constant Field Values
Constructor Detail

CastorSQLContactManagement

public CastorSQLContactManagement()
Method Detail

loadContacts

public JwmaContactsImpl loadContacts(java.lang.String cuid)
                              throws JwmaException
Description copied from interface: ContactManagementPlugin
Loads the given contacts database from the persistent store and returns them as a JwmaContactsImpl instance.

If contacts database with the given identity does not exist on the store, the method returns null.

Specified by:
loadContacts in interface ContactManagementPlugin
Parameters:
cuid - a String representing a unique identifier for a contact database.
Returns:
the JwmaContactsImpl instance.
Throws:
JwmaException - if an I/O error occurs.
See Also:
JwmaContactsImpl, JwmaPreferencesImpl.getContactDatabaseID()

saveContacts

public void saveContacts(JwmaContactsImpl contacts)
                  throws JwmaException
Description copied from interface: ContactManagementPlugin
Saves the given contacts database to the persistent store.

If the contacts database does not exist on the store, the method should create it, otherwise update the existing version.
The unique identity is retrieved using the getUID() method of the given JwmaContactsImpl instance.

Specified by:
saveContacts in interface ContactManagementPlugin
Parameters:
contacts - the JwmaContactsImpl instance to saved.
Throws:
JwmaException - if an I/O error occurs.
See Also:
JwmaContactsImpl, JwmaContacts.getUID()

isPersistent

public boolean isPersistent(java.lang.String cuid)
                     throws JwmaException
Description copied from interface: ContactManagementPlugin
Tests if a given contact database exists on the store.

Specified by:
isPersistent in interface ContactManagementPlugin
Parameters:
cuid - a String representing a unique identifier for a contact database.
Throws:
JwmaException - if an I/O error occurs.
See Also:
JwmaContactsImpl, JwmaPreferencesImpl.getContactDatabaseID()

createContacts

public JwmaContactsImpl createContacts()
Description copied from interface: ContactManagementPlugin
Creates a new contact databse instance.

Specified by:
createContacts in interface ContactManagementPlugin
Returns:
the JwmaContactsImpl instance.
See Also:
JwmaContactsImpl

activate

public void activate()
              throws JwmaException
Description copied from interface: JwmaPlugin
Activates the plugin for subsequent use.

This method is called during bootstrap to allow an implementation to initialize properly. If the plugin cannot perform it's task, it has to throw a JwmaException.

Specified by:
activate in interface JwmaPlugin
Throws:
JwmaException - if initialization failed.

deactivate

public void deactivate()
Description copied from interface: JwmaPlugin
Deactivates the plugin.

This method is called during shutdown or probably on dynamic implementation exchange, to allow an implementation to finalize properly.

Specified by:
deactivate in interface JwmaPlugin

exportContact

public java.lang.String exportContact(JwmaContact contact,
                                      java.lang.String TYPE)
                               throws JwmaException
Description copied from interface: ContactManagementPlugin
Exports a contact in the given type.

Specified by:
exportContact in interface ContactManagementPlugin
Parameters:
contact - the JwmaContact to be exported.
TYPE - the type of the export.
Returns:
the exported contact as String.
JwmaException
See Also:
ContactManagementPlugin.getSupportedTypes(int IMEX_TYPE), ContactManagementPlugin.CONTACT_EXPORT

importContact

public JwmaContact importContact(java.io.InputStream in,
                                 java.lang.String TYPE)
                          throws JwmaException
Description copied from interface: ContactManagementPlugin
Imports a contact of the given type.

Specified by:
importContact in interface ContactManagementPlugin
Parameters:
in - source for importing the contact in the given type.
TYPE - the type of the import source.
Returns:
the imported contact as JwmaContact.
JwmaException
See Also:
ContactManagementPlugin.getSupportedTypes(int IMEX_TYPE), ContactManagementPlugin.CONTACT_IMPORT

importDatabase

public JwmaContact[] importDatabase(java.io.InputStream in,
                                    java.lang.String TYPE)
                             throws JwmaException
Description copied from interface: ContactManagementPlugin
Imports a database of contacts of the given type.

Specified by:
importDatabase in interface ContactManagementPlugin
Parameters:
in - source for importing the contacts in the given type.
Returns:
the imported contacts as JwmaContact[].
JwmaException
See Also:
ContactManagementPlugin.getSupportedTypes(int IMEX_TYPE), ContactManagementPlugin.DATABASE_IMPORT

exportDatabase

public void exportDatabase(java.io.OutputStream out,
                           JwmaContacts db,
                           java.lang.String TYPE)
                    throws JwmaException
Description copied from interface: ContactManagementPlugin
Exports the given contact database in the given type.

Specified by:
exportDatabase in interface ContactManagementPlugin
Parameters:
db - the JwmaContacts database to be exported.
TYPE - the type of the export.
JwmaException
See Also:
ContactManagementPlugin.getSupportedTypes(int IMEX_TYPE), ContactManagementPlugin.DATABASE_EXPORT

getSupportedTypes

public java.lang.String[] getSupportedTypes(int IMEX_TYPE)
Description copied from interface: ContactManagementPlugin
Returns a list of types for the given import/export method. The types from this array can be passed as parameters to the respective import/export method.

Specified by:
getSupportedTypes in interface ContactManagementPlugin
Returns:
an array of String's representing types.

isSupportedContactImportType

public boolean isSupportedContactImportType(java.lang.String type)
Description copied from interface: ContactManagementPlugin
Tests if the given contact type can be imported.

Specified by:
isSupportedContactImportType in interface ContactManagementPlugin
Returns:
true if supported, false otherwise.

Jwma

Copyright © 2000-2003 jwma team (All Rights Reserved.)