Return-Path: X-Original-To: apmail-incubator-syncope-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-syncope-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B893C99CD for ; Wed, 4 Apr 2012 12:50:10 +0000 (UTC) Received: (qmail 20145 invoked by uid 500); 4 Apr 2012 12:50:10 -0000 Delivered-To: apmail-incubator-syncope-commits-archive@incubator.apache.org Received: (qmail 20117 invoked by uid 500); 4 Apr 2012 12:50:10 -0000 Mailing-List: contact syncope-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: syncope-dev@incubator.apache.org Delivered-To: mailing list syncope-commits@incubator.apache.org Received: (qmail 20109 invoked by uid 99); 4 Apr 2012 12:50:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 12:50:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 12:50:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B642223889BB; Wed, 4 Apr 2012 12:49:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: syncope-commits@incubator.apache.org From: ilgrosso@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120404124948.B642223889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 model = new HashMap(); - for (AbstractAttr attr : user.getAttributes()) { - List 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. + -

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 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 -
- Your email address is ${email}. -
\ 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