public class ArchiveContentsEngine extends Object implements Runnable
| Modifier and Type | Field and Description | 
|---|---|
protected AmetysObjectResolver | 
_ametysResolver
The ametys object resolver. 
 | 
protected Set<String> | 
_archiveRights
The user e-mail notification will be sent to users that have this at least one of this rights. 
 | 
protected String | 
_baseUrl
The server base URL. 
 | 
protected Context | 
_context
The avalon context. 
 | 
protected Context | 
_environmentContext
The cocoon environment context. 
 | 
protected I18nUtils | 
_i18nUtils
The i18n utils. 
 | 
protected boolean | 
_initialized
Is the engine initialized ? 
 | 
protected Logger | 
_logger
The logger. 
 | 
protected String | 
_mailFrom
The content of "from" field in emails. 
 | 
protected ServiceManager | 
_manager
The service manager. 
 | 
protected RightManager | 
_rightManager
The rights manager 
 | 
protected SourceResolver | 
_sourceResolver
The avalon source resolver. 
 | 
protected String | 
_sysadminMail
The sysadmin mail address, to which will be sent the report e-mail. 
 | 
protected String | 
_userErrorMailBody
The user notification error mail body i18n key. 
 | 
protected String | 
_userErrorMailSubject
The user notification error mail subject i18n key. 
 | 
protected String | 
_userMailBody
The user notification mail body i18n key. 
 | 
protected String | 
_userMailSubject
The user notification mail subject i18n key. 
 | 
protected UserManager | 
_userManager
The users manager. 
 | 
| Constructor and Description | 
|---|
ArchiveContentsEngine()  | 
| Modifier and Type | Method and Description | 
|---|---|
protected Set<UserIdentity> | 
_getAuthorizedContributors(Content content)
Get the authorized contributors to receive mail notification 
 | 
protected String | 
_getContentsListAsString(List<Content> contents)
Get the contents list as String 
 | 
protected String | 
_getRequestURI(Content content)
Get the request URI to set in mail 
 | 
protected void | 
_sendMailsToUsers(String subject,
                 String body,
                 Set<UserIdentity> users,
                 String from)
Send the emails to users (contributors) 
 | 
protected void | 
archiveContents(Request request)
Get the contents that need to be archived, and archive them. 
 | 
protected void | 
checkInitialization()
Check the initialization and throw an exception if not initialized. 
 | 
void | 
configure(Configuration configuration)
Configure the engine (called by the scheduler). 
 | 
protected void | 
dispose()
Dispose of the resources and looked-up components. 
 | 
protected List<String> | 
getAdminEmailParams(List<Content> archivedContents,
                   List<Content> contentsWithError)
Get the report e-mail parameters. 
 | 
protected String | 
getArchiveActionUri(String contentId)
Get the pipeline uri for the archive action 
 | 
protected List<String> | 
getBodyParamsForContributors(Content content,
                            boolean archived)
Get email body parameters 
 | 
void | 
initialize(ServiceManager manager,
          Context context)
Initialize the archive engine. 
 | 
void | 
run()  | 
protected void | 
sendErrorMailToContributors(Content content,
                           Set<UserIdentity> users)
Send the mail to alert users that an error has occurred while trying to archive the content. 
 | 
protected void | 
sendMailToAdministrator(List<Content> archivedContents,
                       List<Content> contentsWithError)
Send the archive report e-mail. 
 | 
protected void | 
sendMailToContributors(Content content,
                      Set<UserIdentity> users)
Send the mail to alert users that the content has been archived. 
 | 
protected void | 
setRequestAttributes(Request request,
                    Content content)
Set the necessary request attributes 
 | 
protected ServiceManager _manager
protected boolean _initialized
protected Context _environmentContext
protected AmetysObjectResolver _ametysResolver
protected SourceResolver _sourceResolver
protected RightManager _rightManager
protected UserManager _userManager
protected I18nUtils _i18nUtils
protected String _sysadminMail
protected Set<String> _archiveRights
protected String _userMailBody
protected String _userMailSubject
protected String _userErrorMailBody
protected String _userErrorMailSubject
public ArchiveContentsEngine()
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException
manager - the avalon service manager.context - the avalon context.ContextException - If an error occurredServiceException - If an error occurredpublic void configure(Configuration configuration) throws ConfigurationException
configuration - the component configuration.ConfigurationException - If an error occurredprotected void checkInitialization()
protected void dispose()
protected void archiveContents(Request request) throws AmetysRepositoryException, MalformedURLException, IOException
request - The current request objectAmetysRepositoryException - if an error occurs.IOException - If an error occurredMalformedURLException - If an error occurredprotected void setRequestAttributes(Request request, Content content)
request - The requestcontent - The contentprotected String getArchiveActionUri(String contentId)
contentId - the current contend idprotected void sendMailToAdministrator(List<Content> archivedContents, List<Content> contentsWithError)
archivedContents - The list of archived contentscontentsWithError - The list of contents with errorprotected List<String> getAdminEmailParams(List<Content> archivedContents, List<Content> contentsWithError)
archivedContents - The list of archived contentscontentsWithError - The list of contents with errorprotected String _getContentsListAsString(List<Content> contents)
contents - The contentsprotected Set<UserIdentity> _getAuthorizedContributors(Content content)
content - The content to be archivedprotected void sendMailToContributors(Content content, Set<UserIdentity> users)
content - The archived contentusers - The usersprotected List<String> getBodyParamsForContributors(Content content, boolean archived)
content - the archived contentarchived - true if the content has archivedprotected void sendErrorMailToContributors(Content content, Set<UserIdentity> users)
content - The contentusers - The usersprotected String _getRequestURI(Content content)
content - The content. Can be nullprotected void _sendMailsToUsers(String subject, String body, Set<UserIdentity> users, String from)
subject - the e-mail subject.body - the e-mail body.users - users to send the mail to.from - the address sending the e-mail.