Class ImportSubscribersAction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.ServiceableAction
org.ametys.plugins.newsletter.subscribe.ImportSubscribersAction
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,Action
Import subscribers from a CSV or text file.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CategoryProviderExtensionPoint
The category provider extension point.protected SubscribersDAO
The subscribers DAO.Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionact
(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) protected Collection<String>
getEmails
(BOMInputStream bomIS) Extract the emails from the file.protected void
insertSubscribers
(Collection<String> emails, String categoryId, String siteName, Map<String, Object> result) Insert subscribersvoid
service
(ServiceManager smanager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_subscribersDao
The subscribers DAO. -
_categoryProviderEP
The category provider extension point.
-
-
Constructor Details
-
ImportSubscribersAction
public ImportSubscribersAction()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception - Throws:
Exception
-
getEmails
Extract the emails from the file.- Parameters:
bomIS
- the input stream- Returns:
- a collection of the emails.
- Throws:
IOException
- if an error occurs reading the file.
-
insertSubscribers
protected void insertSubscribers(Collection<String> emails, String categoryId, String siteName, Map<String, Object> result) Insert subscribers- Parameters:
emails
- the emails to insertcategoryId
- the id of categorysiteName
- the site name of categoryresult
- the result map
-