cmailleux 2005/12/12 16:25:19 CET
Modified files:
core/src/java/org/jahia/workflow/nstep NStepWorkflow.java
Log:
Avoid sending same mail multiple time to same user
Send email only if user have an email (do not check the validity of the email)
Revision Changes Path
1.17 +26 -16
jahia/core/src/java/org/jahia/workflow/nstep/NStepWorkflow.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/workflow/nstep/NStepWorkflow.java.diff?r1=1.16&r2=1.17&f=h
Index: NStepWorkflow.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/workflow/nstep/NStepWorkflow.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- NStepWorkflow.java 12 Dec 2005 11:55:37 -0000 1.16
+++ NStepWorkflow.java 12 Dec 2005 15:25:18 -0000 1.17
@@ -44,34 +44,39 @@
* Time: 14:53:40
*
* @author [EMAIL PROTECTED]
- * @version $Id: NStepWorkflow.java,v 1.16 2005/12/12 11:55:37 cmailleux Exp
$
+ * @version $Id: NStepWorkflow.java,v 1.17 2005/12/12 15:25:18 cmailleux Exp
$
* <p/>
* Revision log :
* $Log: NStepWorkflow.java,v $
+ * Revision 1.17 2005/12/12 15:25:18 cmailleux
+ * Avoid sending same mail multiple time to same user
+ *
+ * Send email only if user have an email (do not check the validity
of the email)
+ *
* Revision 1.16 2005/12/12 11:55:37 cmailleux
* Avoid ressource excpetion on startstep
- *
+ * <p/>
* Revision 1.15 2005/12/12 11:48:18 cmailleux
* Only Member of admin group can steal workflow lock
- *
+ * <p/>
* Root is allowed to make all step of an NStep Workflow
- *
+ * <p/>
* Correctly close lock engine when clicking cancel
- *
+ * <p/>
* Revision 1.14 2005/12/07 14:17:08 cmailleux
* Change the order of the actions
- *
+ * <p/>
* Revision 1.13 2005/11/30 15:04:42 cmailleux
* no message
- *
+ * <p/>
* Revision 1.12 2005/11/29 14:09:41 cmailleux
* Avoid using jParams to get the group
- *
+ * <p/>
* Revision 1.11 2005/11/22 18:01:45 cmailleux
* Add transactions to nstepWorkflow
* Export with files in production
* COrrectly flush caches when moving
- *
+ * <p/>
* Revision 1.10 2005/10/27 14:44:32 cmailleux
* Avoid deleting workflow if validation is unsuccessfull
* <p/>
@@ -477,7 +482,8 @@
}
}
}
- } else if ( testResults.getStatus() !=
ActivationTestResults.COMPLETED_OPERATION_STATUS) {
+ } else
+ if (testResults.getStatus() !=
ActivationTestResults.COMPLETED_OPERATION_STATUS) {
String s = "Error during finishing of
process ensure that " + jParams.getUser().getUsername() + " user have the
administration rights on the objects you try to validate";
log.error(s);
throw new Exception(s);
@@ -698,12 +704,13 @@
workflow.getAuthorEmail());
final String username = author.getUsername();
String processName =
trimActionName(workflow.getWorkflow().getName().toLowerCase());
- String subject = getKey("process." + processName + ".mail.subject",
workflow, jParams, displayName, comment, username, (startStep)?null:curStep,
+ String subject = getKey("process." + processName + ".mail.subject",
workflow, jParams, displayName, comment, username, (startStep) ? null : curStep,
nextStep, contentObjectInstance);
jParams.removeAttribute("org.jahia.engines.workflow.notify.from");
jParams.removeAttribute("org.jahia.engines.workflow.notify.cc");
jParams.removeAttribute("org.jahia.engines.workflow.notify.bcc");
final MailService mailService =
ServicesRegistry.getInstance().getMailService();
+ Map alreadySendMail = new HashMap(64);
if (startStep) {
// Send an email to the author that is modification have been
refused
mailBody = getKey("process." + processName +
".mail.body.rollback.to.author", workflow, jParams, displayName, comment,
username,
@@ -718,7 +725,7 @@
// sendMails(group, mailService, from, cc, bcc, subject,
mailBody);
// Send mail to group who refuse to validate
group =
workflowService.getRoleGroup(jParams.getContentPage(),
trimActionName(nextStep.getName()), true);
- sendMails(group, mailService, from, cc, bcc, subject,
mailBody);
+ sendMails(group, mailService, from, cc, bcc, subject,
mailBody, alreadySendMail);
} else if (finished) {
if (contentObjectInstance.hasActiveEntries()) {
mailBody = getKey("process." + processName +
".mail.body.finish.published", workflow, jParams, displayName, comment,
username,
@@ -733,27 +740,32 @@
i);
group =
workflowService.getRoleGroup(jParams.getContentPage(),
trimActionName(step.getName()),
true);
- sendMails(group, mailService, from, cc, bcc, subject,
mailBody);
+ sendMails(group, mailService, from, cc, bcc, subject,
mailBody, alreadySendMail);
}
} else {
mailBody = mailBody = getKey("process." + processName +
".mail.body.step.advance", workflow, jParams, displayName,
comment, username, curStep,
nextStep, contentObjectInstance);
group =
workflowService.getRoleGroup(jParams.getContentPage(),
trimActionName(nextStep.getName()),
true);
- sendMails(group, mailService, from, cc, bcc, subject,
mailBody);
+ sendMails(group, mailService, from, cc, bcc, subject,
mailBody, alreadySendMail);
}
- mailService.sendMessage(from, author.getProperty("email"), cc,
bcc, subject, mailBody);
+ String email = author.getProperty("email");
+ if (email != null && alreadySendMail.containsKey(email) &&
!"".equals(email.trim()))
+ mailService.sendMessage(from, email, cc, bcc, subject,
mailBody);
}
}
private void sendMails(JahiaGroup group, final MailService mailService,
String from, String cc, String bcc,
- String subject, String mailBody) {
+ String subject, String mailBody, Map
alreadySendMail) {
Set users = group.getRecursiveUserMembers();
Iterator iterator = users.iterator();
while (iterator.hasNext()) {
JahiaUser user = (JahiaUser) iterator.next();
String email = user.getProperty("email");
- mailService.sendMessage(from, email, cc, bcc, subject, mailBody);
+ if (email != null && alreadySendMail.containsKey(email) &&
!"".equals(email.trim())) {
+ mailService.sendMessage(from, email, cc, bcc, subject,
mailBody);
+ alreadySendMail.put(email, email);
+ }
}
}