}
public Object execute(Map properties) {
Object result = null;
try {
final AuditTrail auditTrail = (AuditTrail) properties.get("auditTrail");
final PluginManager pluginManager = (PluginManager) properties.get("pluginManager");
final WorkflowManager workflowManager = (WorkflowManager) pluginManager.getBean("workflowManager");
final WorkflowUserManager workflowUserManager = (WorkflowUserManager) pluginManager.getBean("workflowUserManager");
final DirectoryManager directoryManager = (DirectoryManager) pluginManager.getBean("directoryManager");
final String base = (String) properties.get("base");
final String smtpHost = (String) properties.get("host");
final String smtpPort = (String) properties.get("port");
final String smtpUsername = (String) properties.get("username");
final String smtpPassword = (String) properties.get("password");
final String security = (String) properties.get("security");
final String from = (String) properties.get("from");
final String cc = (String) properties.get("cc");
final String subject = (String) properties.get("subject");
final String emailMessage = (String) properties.get("emailMessage");
final String url = (String) properties.get("url");
final String urlName = (String) properties.get("urlName");
final String parameterName = (String) properties.get("parameterName");
final String passoverMethod = (String) properties.get("passoverMethod");
final String exclusion = (String) properties.get("exclusion");
final String isHtml = (String) properties.get("isHtml");
Map<String, String> replaceMap = null;
if ("true".equalsIgnoreCase(isHtml)) {
replaceMap = new HashMap<String, String>();
replaceMap.put("\\n", "<br/>");
}
final Map<String, String> replace = replaceMap;
String appId = auditTrail.getAppId();
String appVersion = auditTrail.getAppVersion();
AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
final AppDefinition appDef = appService.getAppDefinition(appId, appVersion);
if (smtpHost == null || smtpHost.trim().length() == 0) {
return null;
}
if (auditTrail != null && (auditTrail.getMethod().equals("createAssignments") || auditTrail.getMethod().equals("getDefaultAssignments") || auditTrail.getMethod().equals("assignmentReassign") || auditTrail.getMethod().equals("assignmentForceComplete"))) {
final String profile = DynamicDataSourceManager.getCurrentProfile();
new Thread(new Runnable() {
public void run() {
ThreadSessionUtil.initSession();
try {
HostManager.setCurrentProfile(profile);
List<String> userList = new ArrayList<String>();
String activityInstanceId = auditTrail.getMessage();
int maxAttempt = 5;
int numOfAttempt = 0;
WorkflowActivity wfActivity = null;
while (userList != null && userList.isEmpty() && numOfAttempt < maxAttempt) {