Class AsyncScriptHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.core.ui.script.ScriptHandler
-
- org.ametys.plugins.core.ui.script.AsyncScriptHandler
-
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Contextualizable
,Serviceable
public class AsyncScriptHandler extends ScriptHandler implements Initializable
Component able to execute scripts asynchronously, either from a schedulable or because the user asked to do so. Script results are sent by email.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AsyncScriptHandler.AsyncResultProcessor
-
Nested classes/interfaces inherited from class org.ametys.plugins.core.ui.script.ScriptHandler
ScriptHandler.ResultProcessor
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__ASYNC_EXECUTE_MAIL_BODY_KEY
private static String
__ASYNC_EXECUTE_MAIL_SUBJECT_ERROR_KEY
private static String
__ASYNC_EXECUTE_MAIL_SUBJECT_KEY
private static String
__ASYNC_EXECUTE_MAIL_UNDEFINED
private Function<String,String>
_mailSenderProvider
static String
COMPONENT_ROLE
Avalon role.-
Fields inherited from class org.ametys.plugins.core.ui.script.ScriptHandler
_context, _currentUserProvider, _i18nUtils, _rightManager, _scriptBindingEP, RIGHT_EXECUTE_SCRIPTS, ROLE
-
-
Constructor Summary
Constructors Constructor Description AsyncScriptHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ZonedDateTime
_getZDTFromScriptResults(Map<String,Object> scriptResults, String paramName)
protected void
_initializeMailSenderProvider()
Initializes_mailSenderProvider
.private String
_mailTitle(String i18nCatalog, String errorStacktrace)
protected ScriptHandler.ResultProcessor
getProcessor()
Returns theScriptHandler.ResultProcessor
used to process script result.void
initialize()
void
sendReportMail(Map<String,Object> scriptResults, UserIdentity user, String mailRecipient, Locale locale, org.slf4j.Logger logger)
Send a mail report from the result of a script-
Methods inherited from class org.ametys.plugins.core.ui.script.ScriptHandler
_executeScript, buildExecArguments, contextualize, executeScript, executeScript, executeScript, getScriptBindingDescription, getWorkspaceName, processScriptResult, service
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
COMPONENT_ROLE
public static final String COMPONENT_ROLE
Avalon role.
-
__ASYNC_EXECUTE_MAIL_SUBJECT_KEY
private static final String __ASYNC_EXECUTE_MAIL_SUBJECT_KEY
- See Also:
- Constant Field Values
-
__ASYNC_EXECUTE_MAIL_SUBJECT_ERROR_KEY
private static final String __ASYNC_EXECUTE_MAIL_SUBJECT_ERROR_KEY
- See Also:
- Constant Field Values
-
__ASYNC_EXECUTE_MAIL_BODY_KEY
private static final String __ASYNC_EXECUTE_MAIL_BODY_KEY
- See Also:
- Constant Field Values
-
__ASYNC_EXECUTE_MAIL_UNDEFINED
private static final String __ASYNC_EXECUTE_MAIL_UNDEFINED
- See Also:
- Constant Field Values
-
_mailSenderProvider
private Function<String,String> _mailSenderProvider
-
-
Constructor Detail
-
AsyncScriptHandler
public AsyncScriptHandler()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
_initializeMailSenderProvider
protected void _initializeMailSenderProvider()
Initializes_mailSenderProvider
. The argument of the provider is the mail of the recipient (as string)
-
getProcessor
protected ScriptHandler.ResultProcessor getProcessor()
Description copied from class:ScriptHandler
Returns theScriptHandler.ResultProcessor
used to process script result.- Overrides:
getProcessor
in classScriptHandler
- Returns:
- the
ScriptHandler.ResultProcessor
.
-
sendReportMail
public void sendReportMail(Map<String,Object> scriptResults, UserIdentity user, String mailRecipient, Locale locale, org.slf4j.Logger logger) throws javax.mail.MessagingException, IOException
Send a mail report from the result of a script- Parameters:
scriptResults
- The result of the scriptuser
- The usermailRecipient
- The recipient of the result maillocale
- The user localelogger
- The logger- Throws:
javax.mail.MessagingException
- If an error occurred while preparing or sending emailIOException
- If an error occurred with an attachment.
-
_getZDTFromScriptResults
private ZonedDateTime _getZDTFromScriptResults(Map<String,Object> scriptResults, String paramName)
-
_mailTitle
private String _mailTitle(String i18nCatalog, String errorStacktrace)
-
-