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/interfaces inherited from class org.ametys.plugins.core.ui.script.ScriptHandler
ScriptHandler.ResultProcessor
-
-
Field Summary
Fields Modifier and Type Field Description 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 protected void
_initializeMailSenderProvider()
Initializes_mailSenderProvider
.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.
-
-
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 jakarta.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:
jakarta.mail.MessagingException
- If an error occurred while preparing or sending emailIOException
- If an error occurred with an attachment.
-
-