001: /***
002: * jwma Java WebMail
003: * Copyright (c) 2000-2003 jwma team
004: *
005: * jwma is free software; you can distribute and use this source
006: * under the terms of the BSD-style license received along with
007: * the distribution.
008: ***/package dtw.webmail.plugin;
009:
010: import dtw.webmail.model.*;
011: import dtw.webmail.JwmaSession;
012:
013: /**
014: * Interface for a plugin that handles persistency of
015: * user preferences.<p>
016: *
017: * @author Dieter Wimberger
018: * @version 0.9.7 07/02/2003
019: */
020: public interface PreferencesPersistencePlugin extends JwmaPlugin {
021:
022: /**
023: * Loads the given user's preferences from the
024: * persistent store and returns them as a <tt>
025: * JwmaPreferencesImpl</tt> instance.
026: * <p>
027: * If preferences for the given user do not exist on
028: * the store, the method returns <tt>null</tt>.
029: *
030: * @param identity a <tt>String</tt> representing the user
031: * (in a unique way).
032: *
033: * @return the <tt>JwmaPreferencesImpl</tt> instance.
034: *
035: * @throws JwmaException if an I/O error occurs.
036: *
037: * @see dtw.webmail.model.JwmaPreferencesImpl
038: * @see dtw.webmail.model.JwmaPreferencesImpl#getUserIdentity()
039: */
040: public JwmaPreferencesImpl loadPreferences(String identity)
041: throws JwmaException;
042:
043: /**
044: * Saves the given preferences to the
045: * persistent store.
046: * <p>
047: * If the preferences do not exist on the store,
048: * the method should create them, otherwise update
049: * the existing version.<br>
050: * The identity is retrieved using the <tt>getUserIdentity()</tt>
051: * method of the given <tt>JwmaPreferencesImpl</tt> instance.
052: *
053: * @param prefs the <tt>JwmaPreferencesImpl</tt> instance to
054: * saved.
055: *
056: * @throws JwmaException if an I/O error occurs.
057: *
058: * @see dtw.webmail.model.JwmaPreferencesImpl
059: * @see dtw.webmail.model.JwmaPreferencesImpl#getUserIdentity()
060: */
061: public void savePreferences(JwmaPreferencesImpl prefs)
062: throws JwmaException;
063:
064: /**
065: * Tests if preferences for the given user exist
066: * on the store.
067: *
068: * @param identity a <tt>String</tt> representing the user
069: * (in a unique way).
070: *
071: * @throws JwmaException if an I/O error occurs.
072: *
073: * @see dtw.webmail.model.JwmaPreferencesImpl#getUserIdentity()
074: */
075: public boolean isPersistent(String identity) throws JwmaException;
076:
077: /**
078: * Returns a copy of the template <tt>JwmaPreferencesImpl</tt>
079: * instance.
080: *
081: * @param session the actual <tt>JwmaSession</tt> instance.
082: * @return the template <tt>JwmaPreferencesImpl</tt> instance.
083: *
084: * @see dtw.webmail.model.JwmaPreferencesImpl
085: */
086: public JwmaPreferencesImpl getPreferencesTemplate(
087: JwmaSession session);
088:
089: /**
090: * Sets the template <tt>JwmaPreferencesImpl</tt>
091: * instance.
092: * <p>
093: * The caller assumes that the plugin handles the persistence
094: * of the passed in template instance.
095: *
096: * @param template <tt>JwmaPreferencesImpl</tt> instance.
097: *
098: * @throws JwmaException if an I/O error occurs.
099: *
100: * @see dtw.webmail.model.JwmaPreferencesImpl
101: */
102: public void setPreferencesTemplate(JwmaPreferencesImpl template)
103: throws JwmaException;
104:
105: }//interface PreferencesPersistencePlugin
|