[Yanel-commits] rev 57321 - public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow

michi at wyona.com michi at wyona.com
Tue Mar 15 11:42:01 CET 2011


Author: michi
Date: 2011-03-15 11:42:01 +0100 (Tue, 15 Mar 2011)
New Revision: 57321

Modified:
   public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/EmailAction.java
Log:
send emails

Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/EmailAction.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/EmailAction.java	2011-03-15 09:56:21 UTC (rev 57320)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/EmailAction.java	2011-03-15 10:42:01 UTC (rev 57321)
@@ -15,6 +15,7 @@
  */
 package org.wyona.yanel.impl.workflow;
 
+import org.wyona.yanel.core.Resource;
 import org.wyona.yanel.core.api.attributes.WorkflowableV1;
 import org.wyona.yanel.core.workflow.Action;
 import org.wyona.yanel.core.workflow.Workflow;
@@ -43,9 +44,17 @@
      */
     public void execute(WorkflowableV1 workflowable, Workflow workflow, String revision) throws WorkflowException {
         String[] emailAddresses = getEmailAddresses();
+        String from = getSenderAddress(workflowable, workflow, revision);
+        String subject = getSubject(workflowable, workflow, revision);
+        String content = getText(workflowable, workflow, revision);
         if (emailAddresses != null) {
             for (int i = 0; i < emailAddresses.length; i++) {
-                log.warn("Send email to: " + emailAddresses[i]);
+                log.info("Send email to: " + emailAddresses[i]);
+                try {
+                    org.wyona.yanel.core.util.MailUtil.send(from, emailAddresses[i], subject, content);
+                } catch(Exception e) {
+                    throw new WorkflowException(e);
+                }
             }
         } else {
             throw new WorkflowException("No email addresses!");
@@ -71,4 +80,27 @@
             return null;
         }
     }
+
+    /**
+     * Get from/sender address
+     */
+    protected String getSenderAddress(WorkflowableV1 workflowable, Workflow workflow, String revision) throws WorkflowException {
+        return "contact at wyona.com";
+    }
+
+    /**
+     * Get subject
+     */
+    protected String getSubject(WorkflowableV1 workflowable, Workflow workflow, String revision) throws WorkflowException {
+        Resource resource = (Resource) workflowable;
+        return "[Yanel] The workflow state of the resource '" + resource.getPath() + "' has been changed: " + workflowable.getWorkflowState(revision);
+    }
+
+    /**
+     * Get text
+     */
+    protected String getText(WorkflowableV1 workflowable, Workflow workflow, String revision) throws WorkflowException {
+        Resource resource = (Resource) workflowable;
+        return "Please review the workflow state change of the resource: " + resource.getPath();
+    }
 }



More information about the Yanel-commits mailing list