-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b79537
commit aece999
Showing
4 changed files
with
55 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/AsyncEmailActionlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.dotmarketing.portlets.workflows.actionlet; | ||
|
||
import com.dotcms.api.system.event.message.MessageSeverity; | ||
import com.dotcms.api.system.event.message.SystemMessageEventUtil; | ||
import com.dotcms.api.system.event.message.builder.SystemMessageBuilder; | ||
import com.dotcms.concurrent.DotConcurrentFactory; | ||
import com.dotmarketing.portlets.workflows.model.WorkflowProcessor; | ||
import com.dotmarketing.util.Mailer; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Same of the {@link EmailActionlet} but runs asynchronously. | ||
* @author jsanca | ||
*/ | ||
public class AsyncEmailActionlet extends EmailActionlet { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
protected final SystemMessageEventUtil systemMessageEventUtil = | ||
SystemMessageEventUtil.getInstance(); | ||
|
||
|
||
@Override | ||
public String getName() { | ||
return "Async Send an Email"; | ||
} | ||
|
||
@Override | ||
protected void sendEmail(final Mailer mail, final WorkflowProcessor processor) { | ||
DotConcurrentFactory.getInstance().getSubmitter().submit(()->{ | ||
try { | ||
mail.sendMessage(); | ||
} catch (Exception e) { | ||
|
||
final List<String> userList = new ArrayList<>(); | ||
userList.add(processor.getUser().getUserId()); | ||
this.systemMessageEventUtil.pushMessage(new SystemMessageBuilder().setMessage("Error sending the email: " + e.getMessage()) | ||
.setLife(5000) | ||
.setSeverity(MessageSeverity.ERROR).create(), userList); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters