com.openexchange.mail.usersetting
Class CachingUserSettingMailStorage

java.lang.Object
  extended by com.openexchange.mail.usersetting.UserSettingMailStorage
      extended by com.openexchange.mail.usersetting.CachingUserSettingMailStorage
All Implemented Interfaces:
com.openexchange.cache.registry.CacheAvailabilityListener

public final class CachingUserSettingMailStorage
extends UserSettingMailStorage

CachingUserSettingMailStorage - this storage tries to use a cache for instances of UserSettingMail and falls back to database-based storage if any cache-related errors occur

Author:
Thorben Betten

Method Summary
 void clearStorage()
          Clears this storage's cache if any used
 void deleteUserSettingMail(int user, com.openexchange.groupware.contexts.Context ctx, java.sql.Connection writeConArg)
          Deletes the user's mail settings from database
 void handleAbsence()
          Handles the (possibly temporary) absence of cache service
 void handleAvailability()
          Handles the (re-)availability of cache service
 UserSettingMail loadUserSettingMail(int user, com.openexchange.groupware.contexts.Context ctx, java.sql.Connection readConArg)
          Loads user's mail settings from database
 void removeUserSettingMail(int user, com.openexchange.groupware.contexts.Context ctx)
          Removes the user's mail settings from cache if any used
 void saveUserSettingMail(UserSettingMail usm, int user, com.openexchange.groupware.contexts.Context ctx, java.sql.Connection writeConArg)
          Saves given user's mail settings to database
 void shutdownStorage()
          Triggers necessary action to shutdown the storage
 
Methods inherited from class com.openexchange.mail.usersetting.UserSettingMailStorage
deleteUserSettingMail, getInstance, getUserSettingMail, getUserSettingMail, getUserSettingMail, loadUserSettingMail, releaseInstance, saveUserSettingMail
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

saveUserSettingMail

public void saveUserSettingMail(UserSettingMail usm,
                                int user,
                                com.openexchange.groupware.contexts.Context ctx,
                                java.sql.Connection writeConArg)
                         throws com.openexchange.groupware.userconfiguration.UserConfigurationException
Saves given user's mail settings to database

Specified by:
saveUserSettingMail in class UserSettingMailStorage
Parameters:
usm - the user's mail settings to save
user - the user ID
ctx - the context
writeConArg - - the writable connection; may be null
Throws:
com.openexchange.groupware.userconfiguration.UserConfigurationException - if user's mail settings could not be saved

deleteUserSettingMail

public void deleteUserSettingMail(int user,
                                  com.openexchange.groupware.contexts.Context ctx,
                                  java.sql.Connection writeConArg)
                           throws com.openexchange.groupware.userconfiguration.UserConfigurationException
Deletes the user's mail settings from database

Specified by:
deleteUserSettingMail in class UserSettingMailStorage
Parameters:
user - the user ID
ctx - the context
writeConArg - the writable connection; may be null
Throws:
com.openexchange.groupware.userconfiguration.UserConfigurationException - - if deletion fails

loadUserSettingMail

public UserSettingMail loadUserSettingMail(int user,
                                           com.openexchange.groupware.contexts.Context ctx,
                                           java.sql.Connection readConArg)
                                    throws com.openexchange.groupware.userconfiguration.UserConfigurationException
Loads user's mail settings from database

Specified by:
loadUserSettingMail in class UserSettingMailStorage
Parameters:
user - the user
ctx - the context
readConArg - the readable connection; may be null to fetch own connection.
Returns:
The instance of UserSettingMail which matches given user ID and context
Throws:
com.openexchange.groupware.userconfiguration.UserConfigurationException - if loading fails

clearStorage

public void clearStorage()
                  throws com.openexchange.groupware.userconfiguration.UserConfigurationException
Description copied from class: UserSettingMailStorage
Clears this storage's cache if any used

Specified by:
clearStorage in class UserSettingMailStorage
Throws:
com.openexchange.groupware.userconfiguration.UserConfigurationException - if cache clearing fails

removeUserSettingMail

public void removeUserSettingMail(int user,
                                  com.openexchange.groupware.contexts.Context ctx)
                           throws com.openexchange.groupware.userconfiguration.UserConfigurationException
Description copied from class: UserSettingMailStorage
Removes the user's mail settings from cache if any used

Specified by:
removeUserSettingMail in class UserSettingMailStorage
Parameters:
user - the user
ctx - the context
Throws:
com.openexchange.groupware.userconfiguration.UserConfigurationException - if cache removal fails

shutdownStorage

public void shutdownStorage()
Description copied from class: UserSettingMailStorage
Triggers necessary action to shutdown the storage

Specified by:
shutdownStorage in class UserSettingMailStorage

handleAbsence

public void handleAbsence()
                   throws com.openexchange.groupware.AbstractOXException
Description copied from interface: com.openexchange.cache.registry.CacheAvailabilityListener
Handles the (possibly temporary) absence of cache service

Throws:
com.openexchange.groupware.AbstractOXException - If an error occurs

handleAvailability

public void handleAvailability()
                        throws com.openexchange.groupware.AbstractOXException
Description copied from interface: com.openexchange.cache.registry.CacheAvailabilityListener
Handles the (re-)availability of cache service

Throws:
com.openexchange.groupware.AbstractOXException - If an error occurs