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 2014/08/04 15:54:55 UTC
svn commit: r1615560 - in /syncope/trunk: ./
core/src/main/java/org/apache/syncope/core/notification/
core/src/main/java/org/apache/syncope/core/rest/controller/
core/src/main/java/org/apache/syncope/core/util/ core/src/main/resources/
core/src/main/re...
Author: ilgrosso
Date: Mon Aug 4 13:54:54 2014
New Revision: 1615560
URL: http://svn.apache.org/r1615560
Log:
[SYNCOPE-138] Merge from 1_2_X
Added:
syncope/trunk/core/src/main/java/org/apache/syncope/core/util/SpringVelocityResourceLoader.java
- copied unchanged from r1615559, syncope/branches/1_2_X/core/src/main/java/org/apache/syncope/core/util/SpringVelocityResourceLoader.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VelocityEngineFactoryBean.java
- copied unchanged from r1615559, syncope/branches/1_2_X/core/src/main/java/org/apache/syncope/core/util/VelocityEngineFactoryBean.java
Modified:
syncope/trunk/ (props changed)
syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ResourceWithFallbackLoader.java
syncope/trunk/core/src/main/resources/coreContext.xml
syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm
syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm
syncope/trunk/core/src/main/resources/workflowContext.xml
syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml
syncope/trunk/deb/core/pom.xml
Propchange: syncope/trunk/
------------------------------------------------------------------------------
Merged /syncope/branches/1_2_X:r1615536-1615559
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=1615560&r1=1615559&r2=1615560&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 Aug 4 13:54:54 2014
@@ -83,6 +83,12 @@ public class NotificationManager {
*/
private static final Logger LOG = LoggerFactory.getLogger(NotificationManager.class);
+ public static final String MAIL_TEMPLATES = "mailTemplates/";
+
+ public static final String MAIL_TEMPLATE_HTML_SUFFIX = ".html.vm";
+
+ public static final String MAIL_TEMPLATE_TEXT_SUFFIX = ".txt.vm";
+
/**
* Notification DAO.
*/
@@ -209,8 +215,10 @@ public class NotificationManager {
task.setSender(notification.getSender());
task.setSubject(notification.getSubject());
- String htmlBody = mergeTemplateIntoString("mailTemplates/" + notification.getTemplate() + ".html.vm", model);
- String textBody = mergeTemplateIntoString("mailTemplates/" + notification.getTemplate() + ".txt.vm", model);
+ String htmlBody = mergeTemplateIntoString(
+ MAIL_TEMPLATES + notification.getTemplate() + MAIL_TEMPLATE_HTML_SUFFIX, model);
+ String textBody = mergeTemplateIntoString(
+ MAIL_TEMPLATES + notification.getTemplate() + MAIL_TEMPLATE_TEXT_SUFFIX, model);
task.setHtmlBody(htmlBody);
task.setTextBody(textBody);
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java?rev=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java Mon Aug 4 13:54:54 2014
@@ -27,15 +27,16 @@ import org.apache.syncope.common.to.Attr
import org.apache.syncope.common.to.ConfTO;
import org.apache.syncope.core.init.ImplementationClassNamesLoader;
import org.apache.syncope.core.init.WorkflowAdapterLoader;
+import org.apache.syncope.core.notification.NotificationManager;
import org.apache.syncope.core.persistence.beans.conf.CAttr;
import org.apache.syncope.core.persistence.dao.ConfDAO;
import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.persistence.validation.attrvalue.Validator;
import org.apache.syncope.core.rest.data.ConfigurationDataBinder;
import org.apache.syncope.core.util.ContentExporter;
+import org.apache.syncope.core.util.ResourceWithFallbackLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -55,8 +56,8 @@ public class ConfigurationController ext
@Autowired
private ImplementationClassNamesLoader classNamesLoader;
- @Autowired
- private ResourcePatternResolver resResolver;
+ @javax.annotation.Resource(name = "velocityResourceLoader")
+ private ResourceWithFallbackLoader resourceLoader;
@Autowired
private WorkflowAdapterLoader wfAdapterLoader;
@@ -97,14 +98,16 @@ public class ConfigurationController ext
Set<String> textTemplates = new HashSet<String>();
try {
- for (Resource resource : resResolver.getResources("classpath:/mailTemplates/*.vm")) {
+ for (Resource resource : resourceLoader.getResources(NotificationManager.MAIL_TEMPLATES + "*.vm")) {
String template = resource.getURL().toExternalForm();
- if (template.endsWith(".html.vm")) {
+ if (template.endsWith(NotificationManager.MAIL_TEMPLATE_HTML_SUFFIX)) {
htmlTemplates.add(
- template.substring(template.indexOf("mailTemplates/") + 14, template.indexOf(".html.vm")));
- } else if (template.endsWith(".txt.vm")) {
+ template.substring(template.indexOf(NotificationManager.MAIL_TEMPLATES) + 14,
+ template.indexOf(NotificationManager.MAIL_TEMPLATE_HTML_SUFFIX)));
+ } else if (template.endsWith(NotificationManager.MAIL_TEMPLATE_TEXT_SUFFIX)) {
textTemplates.add(
- template.substring(template.indexOf("mailTemplates/") + 14, template.indexOf(".txt.vm")));
+ template.substring(template.indexOf(NotificationManager.MAIL_TEMPLATES) + 14,
+ template.indexOf(NotificationManager.MAIL_TEMPLATE_TEXT_SUFFIX)));
} else {
LOG.warn("Unexpected template found: {}, ignoring...", template);
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ResourceWithFallbackLoader.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ResourceWithFallbackLoader.java?rev=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ResourceWithFallbackLoader.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ResourceWithFallbackLoader.java Mon Aug 4 13:54:54 2014
@@ -18,13 +18,17 @@
*/
package org.apache.syncope.core.util;
+import java.io.IOException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.ResourcePatternResolver;
-public class ResourceWithFallbackLoader implements ResourceLoaderAware {
+public class ResourceWithFallbackLoader implements ResourceLoaderAware, ResourcePatternResolver {
- private ResourceLoader resourceLoader;
+ private ResourcePatternResolver resolver;
private String primary;
@@ -32,7 +36,7 @@ public class ResourceWithFallbackLoader
@Override
public void setResourceLoader(final ResourceLoader resourceLoader) {
- this.resourceLoader = resourceLoader;
+ this.resolver = (ResourcePatternResolver) resourceLoader;
}
public void setPrimary(final String primary) {
@@ -43,16 +47,36 @@ public class ResourceWithFallbackLoader
this.fallback = fallback;
}
- public Resource getResource() {
- Resource resource = resourceLoader.getResource(primary);
- if (!resource.exists()) {
- resource = resourceLoader.getResource(fallback);
- }
+ @Override
+ public Resource getResource(final String location) {
+ Resource resource = resolver.getResource(primary + location);
if (!resource.exists()) {
- throw new IllegalArgumentException("Neither " + primary + " nor " + fallback + " were found.");
+ resource = resolver.getResource(fallback + location);
}
return resource;
}
+ public Resource getResource() {
+ return getResource(StringUtils.EMPTY);
+ }
+
+ @Override
+ public Resource[] getResources(final String locationPattern) throws IOException {
+ Resource[] resources = resolver.getResources(primary + locationPattern);
+ if (ArrayUtils.isEmpty(resources)) {
+ resources = resolver.getResources(fallback + locationPattern);
+ }
+
+ return resources;
+ }
+
+ public Resource[] getResources() throws IOException {
+ return getResources(StringUtils.EMPTY);
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return resolver.getClassLoader();
+ }
}
Modified: syncope/trunk/core/src/main/resources/coreContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/coreContext.xml?rev=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/coreContext.xml (original)
+++ syncope/trunk/core/src/main/resources/coreContext.xml Mon Aug 4 13:54:54 2014
@@ -96,8 +96,6 @@ under the License.
<bean id="propagationTaskExecutor" class="org.apache.syncope.core.propagation.impl.PriorityPropagationTaskExecutor"/>
<bean id="propagationReporter" class="org.apache.syncope.core.propagation.impl.DefaultPropagationReporter" scope="prototype"/>
- <bean id="notificationManager" class="org.apache.syncope.core.notification.NotificationManager"/>
-
<bean id="auditManager" class="org.apache.syncope.core.audit.AuditManager"/>
<bean id="connIdBundleManager" class="org.apache.syncope.core.util.ConnIdBundleManager" scope="singleton">
@@ -108,6 +106,8 @@ under the License.
<bean id="syncUtilities" class="org.apache.syncope.core.sync.SyncUtilities"/>
+ <bean id="notificationManager" class="org.apache.syncope.core.notification.NotificationManager"/>
+
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="defaultEncoding" value="${smtpEncoding}"/>
<property name="host" value="${smtpHost}"/>
@@ -124,6 +124,20 @@ under the License.
</property>
</bean>
+ <bean id="velocityResourceLoader" class="org.apache.syncope.core.util.ResourceWithFallbackLoader">
+ <property name="primary" value="file:${conf.directory}/"/>
+ <property name="fallback" value="classpath:"/>
+ </bean>
+ <bean id="velocityEngine" class="org.apache.syncope.core.util.VelocityEngineFactoryBean">
+ <property name="resourceLoader" ref="velocityResourceLoader"/>
+ </bean>
+ <bean id="velocityToolManager" class="org.apache.velocity.tools.ToolManager">
+ <!-- autoConfigure -->
+ <constructor-arg index="0" value="true"/>
+ <!-- include default velocity tools -->
+ <constructor-arg index="1" value="true"/>
+ </bean>
+
<task:annotation-driven executor="connectorExecutor"/>
<task:executor id="connectorExecutor" pool-size="10"/>
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=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm (original)
+++ syncope/trunk/core/src/main/resources/mailTemplates/optin.html.vm Mon Aug 4 13:54:54 2014
@@ -15,7 +15,6 @@ software distributed under the License i
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-
-->
<html>
<body>
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=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm (original)
+++ syncope/trunk/core/src/main/resources/mailTemplates/optin.txt.vm Mon Aug 4 13:54:54 2014
@@ -1,14 +1,19 @@
-# 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
+# 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
+# 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.
+# 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 $user.getAttrMap().get("firstname").getValues().get(0) $user.getAttrMap().get("surname").getValues().get(0), welcome to Syncope!
Your username is $user.getUsername().
Modified: syncope/trunk/core/src/main/resources/workflowContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/workflowContext.xml?rev=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/workflowContext.xml (original)
+++ syncope/trunk/core/src/main/resources/workflowContext.xml Mon Aug 4 13:54:54 2014
@@ -78,20 +78,5 @@ under the License.
<bean id="formService" factory-bean="processEngine" factory-method="getFormService"/>
<context:component-scan base-package="org.apache.syncope.core.workflow.user.activiti"/>
-
- <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
- <property name="velocityProperties">
- <value>
- resource.loader=class
- class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
- </value>
- </property>
- </bean>
-
- <bean id="velocityToolManager" class="org.apache.velocity.tools.ToolManager">
- <!-- autoConfigure -->
- <constructor-arg index="0" value="true"/>
- <!-- include default velocity tools -->
- <constructor-arg index="1" value="true"/>
- </bean>
+
</beans>
Modified: syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml?rev=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml (original)
+++ syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml Mon Aug 4 13:54:54 2014
@@ -29,19 +29,4 @@ under the License.
<bean id="uwfAdapter" class="${uwfAdapter}"/>
<bean id="rwfAdapter" class="${rwfAdapter}"/>
- <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
- <property name="velocityProperties">
- <value>
- resource.loader=class
- class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
- </value>
- </property>
- </bean>
-
- <bean id="velocityToolManager" class="org.apache.velocity.tools.ToolManager">
- <!-- autoConfigure -->
- <constructor-arg index="0" value="true"/>
- <!-- include default velocity tools -->
- <constructor-arg index="1" value="true"/>
- </bean>
</beans>
Modified: syncope/trunk/deb/core/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/deb/core/pom.xml?rev=1615560&r1=1615559&r2=1615560&view=diff
==============================================================================
--- syncope/trunk/deb/core/pom.xml (original)
+++ syncope/trunk/deb/core/pom.xml Mon Aug 4 13:54:54 2014
@@ -57,6 +57,7 @@ under the License.
<includes>
<include>*.properties</include>
<include>*.xml</include>
+ <include>mailTemplates/*.vm</include>
</includes>
<excludes>
<exclude>*Context*.xml</exclude>