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/07 18:19:14 UTC

svn commit: r1429908 - in /syncope/trunk: ./ core/src/main/java/org/apache/syncope/core/notification/ core/src/main/resources/mailTemplates/

Author: ilgrosso
Date: Mon Jan  7 17:19:13 2013
New Revision: 1429908

URL: http://svn.apache.org/viewvc?rev=1429908&view=rev
Log:
[SYNCOPE-263] Merge from 1_0_X

Modified:
    syncope/trunk/   (props changed)
    syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationJob.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
    syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm
    syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_0_X:r1429730-1429899

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationJob.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationJob.java?rev=1429908&r1=1429907&r2=1429908&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationJob.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationJob.java Mon Jan  7 17:19:13 2013
@@ -24,7 +24,6 @@ import java.util.Date;
 import javax.mail.internet.MimeMessage;
 import org.apache.commons.lang.StringUtils;
 import org.apache.syncope.core.audit.AuditManager;
-import org.apache.syncope.core.notification.NotificationManager;
 import org.apache.syncope.core.persistence.beans.NotificationTask;
 import org.apache.syncope.core.persistence.beans.TaskExec;
 import org.apache.syncope.core.persistence.dao.ConfDAO;
@@ -116,21 +115,28 @@ 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());
 
             if (task.getTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal()) {
-
                 execution.setMessage(message);
             }
         } else {
             if (LOG.isDebugEnabled()) {
-                LOG.debug("About to send e-mails:\n" + smtpHost + ":" + smtpPort + "\n" + task.getRecipients() + "\n"
-                        + task.getSender() + "\n" + task.getSubject() + "\n" + task.getHtmlBody() + "\n"
+                LOG.debug("About to send e-mails:\n"
+                        + smtpHost + ":" + smtpPort + "\n"
+                        + task.getRecipients() + "\n"
+                        + task.getSender() + "\n"
+                        + task.getSubject() + "\n"
+                        + task.getHtmlBody() + "\n"
                         + task.getTextBody() + "\n");
             }
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java?rev=1429908&r1=1429907&r2=1429908&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java Mon Jan  7 17:19:13 2013
@@ -24,7 +24,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.syncope.core.connid.ConnObjectUtil;
 import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.Notification;
@@ -160,6 +159,8 @@ 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("events", notification.getEvents());
 
         String htmlBody;
         String textBody;
@@ -219,18 +220,22 @@ public class NotificationManager {
             case Username:
                 email = user.getUsername();
                 break;
+
             case UserSchema:
                 UAttr attr = user.getAttribute(recipientAttrName);
                 email = attr == null || attr.getValuesAsStrings().isEmpty() ? null : attr.getValuesAsStrings().get(0);
                 break;
+
             case UserVirtualSchema:
                 UVirAttr virAttr = user.getVirtualAttribute(recipientAttrName);
                 email = virAttr == null || virAttr.getValues().isEmpty() ? null : virAttr.getValues().get(0);
                 break;
+
             case UserDerivedSchema:
                 UDerAttr derAttr = user.getDerivedAttribute(recipientAttrName);
                 email = derAttr == null ? null : derAttr.getValue(user.getAttributes());
                 break;
+
             default:
                 email = null;
         }

Modified: syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm?rev=1429908&r1=1429907&r2=1429908&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm (original)
+++ syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm Mon Jan  7 17:19:13 2013
@@ -26,6 +26,22 @@ under the License.
    Your email address is $user.getAttributeMap().get("email").getValues().get(0).
 </p>
 
+<p>
+    This message was sent to the following recipients:
+<ul>
+#foreach($recipient in $recipients)
+  <li>$recipient</i>
+#end
+</ul>
+
+becase one of the following events occurred:
+<ul>
+#foreach($event in $events)
+  <li>$event</i>
+#end
+</ul>
+</p>
+
 #if(!$user.getMemberships().isEmpty())
 You have been provided with the following roles:
 <ul>

Modified: syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm?rev=1429908&r1=1429907&r2=1429908&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm (original)
+++ syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm Mon Jan  7 17:19:13 2013
@@ -14,6 +14,16 @@ Hi $user.getAttributeMap().get("firstnam
 Your username is $user.getUsername().
 Your email address is $user.getAttributeMap().get("email").getValues().get(0).
 
+This message was sent to the following recipients:
+#foreach($recipient in $recipients)
+   * $recipient
+#end
+
+becase one of the following events occurred:
+#foreach($event in $events)
+  * $event
+#end
+
 #if(!$user.getMemberships().isEmpty())
 You have been provided with the following roles:
 #foreach($membership in $user.getMemberships())