Class NewsletterUserPreferencesStorage
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.newsletter.userpref.NewsletterUserPreferencesStorage
-
- All Implemented Interfaces:
UserPreferencesStorage,Component,LogEnabled,Serviceable
public class NewsletterUserPreferencesStorage extends AbstractLogEnabled implements UserPreferencesStorage, Component, Serviceable
Retrieves and stores newsletter user preferences values as subscriptions.
-
-
Field Summary
Fields Modifier and Type Field Description protected CategoryProviderExtensionPoint_categoryEPThe category provider extension point.protected UserManager_foUserManagerThe front-office users manager.protected SubscribersDAO_subscribersDaoThe subscribers DAO.
-
Constructor Summary
Constructors Constructor Description NewsletterUserPreferencesStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,String>getExistingCategoryIds(String email, String siteName)Get the existing subscriptions for a user in a given site.protected SubscribergetSubscription(String siteName, User user, String categoryId)Create a subscriber object from the given input.protected SubscribergetSubscription(String siteName, User user, String categoryId, boolean generateDateAndToken)Create a subscriber object from the given input.Map<String,String>getUnTypedUserPrefs(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars)Get a user's preference values (as String) for a given context.BooleangetUserPreferenceAsBoolean(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id)Get a single boolean user preference value for a given context.DategetUserPreferenceAsDate(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id)Get a single date user preference value for a given context.DoublegetUserPreferenceAsDouble(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id)Get a single double user preference value for a given context.LonggetUserPreferenceAsLong(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id)Get a single long user preference value for a given context.StringgetUserPreferenceAsString(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id)Get a single string user preference value for a given context.voidremoveUserPreferences(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars)Remove the stored user preferences for a login in a given context.voidservice(ServiceManager serviceManager)voidsetUserPreferences(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, Map<String,String> preferences)Set a user's preferences for a given context.-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_foUserManager
protected UserManager _foUserManager
The front-office users manager.
-
_categoryEP
protected CategoryProviderExtensionPoint _categoryEP
The category provider extension point.
-
_subscribersDao
protected SubscribersDAO _subscribersDao
The subscribers DAO.
-
-
Constructor Detail
-
NewsletterUserPreferencesStorage
public NewsletterUserPreferencesStorage()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getUnTypedUserPrefs
public Map<String,String> getUnTypedUserPrefs(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a user's preference values (as String) for a given context.- Specified by:
getUnTypedUserPrefsin interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elements- Returns:
- the user preference values as a Map of String indexed by preference ID.
- Throws:
UserPreferencesException- if an error occurs getting the preferences.
-
setUserPreferences
public void setUserPreferences(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, Map<String,String> preferences) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageSet a user's preferences for a given context.- Specified by:
setUserPreferencesin interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementspreferences- a Map of the preference values indexed by ID.- Throws:
UserPreferencesException- if an error occurred
-
removeUserPreferences
public void removeUserPreferences(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageRemove the stored user preferences for a login in a given context.- Specified by:
removeUserPreferencesin interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- the context variables.- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsString
public String getUserPreferenceAsString(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single string user preference value for a given context.- Specified by:
getUserPreferenceAsStringin interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a String.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsLong
public Long getUserPreferenceAsLong(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single long user preference value for a given context.- Specified by:
getUserPreferenceAsLongin interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Long.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsDate
public Date getUserPreferenceAsDate(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single date user preference value for a given context.- Specified by:
getUserPreferenceAsDatein interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Date.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsBoolean
public Boolean getUserPreferenceAsBoolean(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single boolean user preference value for a given context.- Specified by:
getUserPreferenceAsBooleanin interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Boolean.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsDouble
public Double getUserPreferenceAsDouble(UserIdentity userIdentity, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single double user preference value for a given context.- Specified by:
getUserPreferenceAsDoublein interfaceUserPreferencesStorage- Parameters:
userIdentity- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Double.
- Throws:
UserPreferencesException- if an error occurred
-
getSubscription
protected Subscriber getSubscription(String siteName, User user, String categoryId)
Create a subscriber object from the given input.- Parameters:
siteName- the site name.user- the user.categoryId- the category ID.- Returns:
- the Subscriber object.
-
getSubscription
protected Subscriber getSubscription(String siteName, User user, String categoryId, boolean generateDateAndToken)
Create a subscriber object from the given input.- Parameters:
siteName- the site name.user- the user.categoryId- the category ID.generateDateAndToken- true to generate a token and set the subscription date, false otherwise.- Returns:
- the Subscriber object.
-
-