syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1309361 - in /incubator/syncope/trunk/core/src/main: java/org/syncope/core/notification/NotificationManager.java resources/mailTemplates/optin.html.vm resources/mailTemplates/optin.txt.vm
Date Wed, 04 Apr 2012 12:49:48 GMT
Author: ilgrosso
Date: Wed Apr  4 12:49:48 2012
New Revision: 1309361

URL: http://svn.apache.org/viewvc?rev=1309361&view=rev
Log:
[SYNCOPE-53] Now all UserTO information is available in mail templates by using Velocity Template
Language (VTL) - some examples included

Modified:
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/notification/NotificationManager.java
    incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm
    incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/notification/NotificationManager.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/notification/NotificationManager.java?rev=1309361&r1=1309360&r2=1309361&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/notification/NotificationManager.java
(original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/notification/NotificationManager.java
Wed Apr  4 12:49:48 2012
@@ -19,6 +19,7 @@
 package org.syncope.core.notification;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -32,7 +33,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.ui.velocity.VelocityEngineUtils;
-import org.syncope.core.persistence.beans.AbstractAttr;
 import org.syncope.core.persistence.beans.Notification;
 import org.syncope.core.persistence.beans.NotificationTask;
 import org.syncope.core.persistence.beans.TaskExec;
@@ -47,6 +47,7 @@ import org.syncope.core.persistence.dao.
 import org.syncope.core.persistence.dao.TaskExecDAO;
 import org.syncope.core.persistence.dao.UserDAO;
 import org.syncope.core.persistence.dao.UserSearchDAO;
+import org.syncope.core.rest.data.UserDataBinder;
 import org.syncope.core.scheduling.NotificationJob;
 import org.syncope.core.util.ConnObjectUtil;
 import org.syncope.core.util.EntitlementUtil;
@@ -84,6 +85,9 @@ public class NotificationManager {
     @Autowired
     private UserDAO userDAO;
 
+    @Autowired
+    private UserDataBinder userDataBinder;
+
     /**
      * User Search DAO.
      */
@@ -160,14 +164,7 @@ public class NotificationManager {
         task.setSubject(notification.getSubject());
 
         final Map<String, Object> model = new HashMap<String, Object>();
-        for (AbstractAttr attr : user.getAttributes()) {
-            List<String> values = attr.getValuesAsStrings();
-            model.put(attr.getSchema().getName(), values.isEmpty()
-                    ? ""
-                    : (values.size() == 1
-                    ? values.iterator().next()
-                    : values));
-        }
+        model.put("user", userDataBinder.getUserTO(user));
 
         String htmlBody;
         String textBody;
@@ -255,7 +252,7 @@ public class NotificationManager {
      * @param execution task execution.
      * @return merged task execution.
      */
-    public TaskExec storeExecution(TaskExec execution) {
+    public TaskExec storeExecution(final TaskExec execution) {
         NotificationTask task = taskDAO.find(execution.getTask().getId());
         task.addExec(execution);
         return taskExecDAO.save(execution);

Modified: incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm?rev=1309361&r1=1309360&r2=1309361&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm (original)
+++ incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm Wed Apr  4
12:49:48 2012
@@ -1,20 +1,39 @@
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-->
 <html>
 <body>
-<h3>Hi ${firstname} ${surname}, welcome to Syncope!</h3>
+<h3>Hi $user.getAttributeMap().get("firstname").getValues().get(0) $user.getAttributeMap().get("surname").getValues().get(0),
welcome to Syncope!</h3>
+
+<p>
+   Your username is $user.getUsername().<br/>
+   Your email address is $user.getAttributeMap().get("email").getValues().get(0).
+</p>
+
+#if(!$user.getMemberships().isEmpty())
+You have been provided with the following roles:
+<ul>
+#foreach($membership in $user.getMemberships())
+  <li>$membership.roleName</i>
+#end
+</ul>
+#end
 
-<div>
-   Your email address is <a href="mailto:${email}">${email}</a>.
-</div>
 </body>
 </html>
\ No newline at end of file

Modified: incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm?rev=1309361&r1=1309360&r2=1309361&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm (original)
+++ incubator/syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm Wed Apr  4
12:49:48 2012
@@ -9,6 +9,14 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-Hi ${firstname} ${surname}, welcome to Syncope!
+Hi $user.getAttributeMap().get("firstname").getValues().get(0) $user.getAttributeMap().get("surname").getValues().get(0),
welcome to Syncope!
 
-Your email address is ${email}.
+Your username is $user.getUsername().
+Your email address is $user.getAttributeMap().get("email").getValues().get(0).
+
+#if(!$user.getMemberships().isEmpty())
+You have been provided with the following roles:
+#foreach($membership in $user.getMemberships())
+  * $membership.roleName
+#end
+#end
\ No newline at end of file



Mime
View raw message