You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/01/09 11:49:28 UTC
svn commit: r1430774 - in /syncope/branches/1_0_X/core/src/main:
java/org/apache/syncope/core/notification/
java/org/apache/syncope/core/scheduling/ resources/mailTemplates/
Author: ilgrosso
Date: Wed Jan 9 10:49:27 2013
New Revision: 1430774
URL: http://svn.apache.org/viewvc?rev=1430774&view=rev
Log:
[SYNCOPE-263] Injecting all recipients data, as required
Modified:
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/NotificationJob.java
syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.html.vm
syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.txt.vm
Modified: syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java?rev=1430774&r1=1430773&r2=1430774&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java (original)
+++ syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java Wed Jan 9 10:49:27 2013
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javassist.NotFoundException;
+import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.core.persistence.beans.Notification;
import org.apache.syncope.core.persistence.beans.NotificationTask;
import org.apache.syncope.core.persistence.beans.SyncopeConf;
@@ -37,7 +38,6 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.dao.EntitlementDAO;
import org.apache.syncope.core.persistence.dao.NotificationDAO;
import org.apache.syncope.core.persistence.dao.TaskDAO;
-import org.apache.syncope.core.persistence.dao.TaskExecDAO;
import org.apache.syncope.core.persistence.dao.UserDAO;
import org.apache.syncope.core.persistence.dao.UserSearchDAO;
import org.apache.syncope.core.rest.data.UserDataBinder;
@@ -85,6 +85,9 @@ public class NotificationManager {
@Autowired
private UserDAO userDAO;
+ /**
+ * User data binder.
+ */
@Autowired
private UserDataBinder userDataBinder;
@@ -101,12 +104,6 @@ public class NotificationManager {
private TaskDAO taskDAO;
/**
- * TaskExec DAO.
- */
- @Autowired
- private TaskExecDAO taskExecDAO;
-
- /**
* Velocity template engine.
*/
@Autowired
@@ -142,8 +139,8 @@ public class NotificationManager {
recipients.add(user);
}
- Set<String> recipientEmails = new HashSet<String>();
-
+ final Set<String> recipientEmails = new HashSet<String>();
+ final List<UserTO> recipientTOs = new ArrayList<UserTO>(recipients.size());
for (SyncopeUser recipient : recipients) {
connObjectUtil.retrieveVirAttrValues(recipient);
@@ -154,6 +151,7 @@ public class NotificationManager {
LOG.warn("{} cannot be notified: {} not found", recipient, notification.getRecipientAttrName());
} else {
recipientEmails.add(email);
+ recipientTOs.add(userDataBinder.getUserTO(recipient));
}
}
@@ -166,7 +164,7 @@ public class NotificationManager {
final Map<String, Object> model = new HashMap<String, Object>();
model.put("user", userDataBinder.getUserTO(user));
model.put("syncopeConf", this.findAllSyncopeConfs());
- model.put("recipients", recipientEmails);
+ model.put("recipients", recipientTOs);
model.put("events", notification.getEvents());
String htmlBody;
@@ -224,7 +222,7 @@ public class NotificationManager {
private String getRecipientEmail(
final IntMappingType recipientAttrType, final String recipientAttrName, final SyncopeUser user) {
- final String email;
+ String email = null;
switch (recipientAttrType) {
case Username:
@@ -233,21 +231,26 @@ public class NotificationManager {
case UserSchema:
UAttr attr = user.getAttribute(recipientAttrName);
- email = attr == null || attr.getValuesAsStrings().isEmpty() ? null : attr.getValuesAsStrings().get(0);
+ if (attr != null && !attr.getValuesAsStrings().isEmpty()) {
+ email = attr.getValuesAsStrings().get(0);
+ }
break;
case UserVirtualSchema:
UVirAttr virAttr = user.getVirtualAttribute(recipientAttrName);
- email = virAttr == null || virAttr.getValues().isEmpty() ? null : virAttr.getValues().get(0);
+ if (virAttr != null && !virAttr.getValues().isEmpty()) {
+ email = virAttr.getValues().get(0);
+ }
break;
case UserDerivedSchema:
UDerAttr derAttr = user.getDerivedAttribute(recipientAttrName);
- email = derAttr == null ? null : derAttr.getValue(user.getAttributes());
+ if (derAttr != null) {
+ email = derAttr.getValue(user.getAttributes());
+ }
break;
default:
- email = null;
}
return email;
@@ -279,7 +282,7 @@ public class NotificationManager {
taskDAO.save(task);
}
- public Map<String, String> findAllSyncopeConfs() {
+ protected Map<String, String> findAllSyncopeConfs() {
Map<String, String> syncopeConfMap = new HashMap<String, String>();
for (SyncopeConf conf : confDAO.findAll()) {
syncopeConfMap.put(conf.getKey(), conf.getValue());
Modified: syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/NotificationJob.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/NotificationJob.java?rev=1430774&r1=1430773&r2=1430774&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/NotificationJob.java (original)
+++ syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/NotificationJob.java Wed Jan 9 10:49:27 2013
@@ -113,9 +113,13 @@ public class NotificationJob implements
|| StringUtils.isBlank(task.getSubject()) || task.getRecipients().isEmpty()
|| StringUtils.isBlank(task.getHtmlBody()) || StringUtils.isBlank(task.getTextBody())) {
- String message = "Could not fetch all required information for " + "sending e-mails:\n" + smtpHost + ":"
- + smtpPort + "\n" + task.getRecipients() + "\n" + task.getSender() + "\n" + task.getSubject()
- + "\n" + task.getHtmlBody() + "\n" + task.getTextBody();
+ String message = "Could not fetch all required information for sending e-mails:\n"
+ + smtpHost + ":" + smtpPort + "\n"
+ + task.getRecipients() + "\n"
+ + task.getSender() + "\n"
+ + task.getSubject() + "\n"
+ + task.getHtmlBody() + "\n"
+ + task.getTextBody();
LOG.error(message);
execution.setStatus(Status.NOT_SENT.name());
Modified: syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.html.vm
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.html.vm?rev=1430774&r1=1430773&r2=1430774&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.html.vm (original)
+++ syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.html.vm Wed Jan 9 10:49:27 2013
@@ -30,7 +30,7 @@ under the License.
This message was sent to the following recipients:
<ul>
#foreach($recipient in $recipients)
- <li>$recipient</i>
+ <li>$recipient.getAttributeMap().get("email").getValues().get(0)</li>
#end
</ul>
Modified: syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.txt.vm
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.txt.vm?rev=1430774&r1=1430773&r2=1430774&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.txt.vm (original)
+++ syncope/branches/1_0_X/core/src/main/resources/mailTemplates/optin.txt.vm Wed Jan 9 10:49:27 2013
@@ -16,7 +16,7 @@ Your email address is $user.getAttribute
This message was sent to the following recipients:
#foreach($recipient in $recipients)
- * $recipient
+ * $recipient.getAttributeMap().get("surname").getValues().get(0)
#end
becase one of the following events occurred: