Made Email mapping keys customisable

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@44190 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2012-11-30 11:54:54 +00:00
parent b65d0e0d31
commit 0f7197eb25
9 changed files with 541 additions and 209 deletions

View File

@@ -108,4 +108,15 @@
<property name="permissionService" ref="PermissionService"/> <property name="permissionService" ref="PermissionService"/>
</bean> </bean>
<!-- Base bean definition for customisable email mapping keys bootstrap -->
<bean id="customisableEmailMappingKeyBootstrap"
class="org.alfresco.module.org_alfresco_module_rm.email.CustomisableEmailMappingKeyBootstrap"
init-method="init">
<property name="emailMappingKeyService" ref="emailMappingKeyService"/>
<property name="customisable">
<list>
<!-- Add here new email mapping keys -->
</list>
</property>
</bean>
</beans> </beans>

View File

@@ -1036,6 +1036,71 @@
</property> </property>
</bean> </bean>
<!-- EMail Mapping Key Service -->
<bean id="emailMappingKeyService"
class="org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyServiceImpl" >
<property name="emailMappingKeys">
<list>
<value>Thread-Index</value>
<value>messageFrom</value>
<value>messageTo</value>
<value>messageCc</value>
<value>messageSubject</value>
<value>messageSent</value>
</list>
</property>
</bean>
<bean id="EmailMappingKeyService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">${server.transaction.mode.default}</prop>
</props>
</property>
</bean>
<bean id="EmailMappingKeyService_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor">
<property name="authenticationManager">
<ref bean="authenticationManager"/>
</property>
<property name="accessDecisionManager">
<ref bean="accessDecisionManager"/>
</property>
<property name="afterInvocationManager">
<ref bean="afterInvocationManager"/>
</property>
<property name="objectDefinitionSource">
<value>
<![CDATA[
org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService.getEmailMappingKeys=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService.*=RM_DENY
]]>
</value>
</property>
</bean>
<bean id="EmailMappingKeyService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<list>
<value>org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService</value>
</list>
</property>
<property name="targetName">
<value>emailMappingKeyService</value>
</property>
<property name="interceptorNames">
<list>
<idref local="EmailMappingKeyService_transaction"/>
<idref local="EmailMappingKeyService_security"/>
<idref bean="exceptionTranslator"/>
</list>
</property>
</bean>
<!-- RM Notification Helper --> <!-- RM Notification Helper -->
<bean id="recordsManagementNotificationHelper" class="org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper" > <bean id="recordsManagementNotificationHelper" class="org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper" >

View File

@@ -496,4 +496,11 @@
<property name="dataSetService" ref="DataSetService" /> <property name="dataSetService" ref="DataSetService" />
<property name="siteService" ref="SiteService" /> <property name="siteService" ref="SiteService" />
</bean> </bean>
<!-- REST impl for GET Email Mapping Keys -->
<bean id="webscript.org.alfresco.rma.admin.emailmapkeys.get"
class="org.alfresco.module.org_alfresco_module_rm.script.EmailMapKeysGet"
parent="webscript">
<property name="emailMappingKeyService" ref="EmailMappingKeyService" />
</bean>
</beans> </beans>

View File

@@ -0,0 +1,9 @@
<webscript>
<shortname>RM Email Mapping Keys</shortname>
<description>Gets the list of email mapping keys</description>
<url>/api/rma/admin/emailmapkeys</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction allow="readonly">required</transaction>
<lifecycle>internal</lifecycle>
</webscript>

View File

@@ -0,0 +1,13 @@
<#escape x as jsonUtils.encodeJSONString(x)>
{
"data" :
{
"emailmapkeys":
[
<#list emailmapkeys as emailmapkey>
'${emailmapkey}'<#if emailmapkey_has_next>,</#if>
</#list>
]
}
}
</#escape>

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.email;
import java.util.List;
/**
* Bootstrap bean that indicates that the specified mappings are customisable
*
* @author Tuna Aksoy
* @since 2.1
*/
public class CustomisableEmailMappingKeyBootstrap
{
/** List of mappings to register as customisable */
private List<String> customisable;
/** Email mapping key service */
private EmailMappingKeyService emailMappingKeyService;
/**
* @param customizable list of mappings to register as customisable
*/
public void setCustomisable(List<String> customisable)
{
this.customisable = customisable;
}
/**
* Email mapping key service
*
* @param emailMappingKeyService the email mapping key service
*/
public void setEmailMappingKeyService(EmailMappingKeyService emailMappingKeyService)
{
this.emailMappingKeyService = emailMappingKeyService;
}
/**
* Bean initialisation method
*/
public void init()
{
for (String customEmailMappingKey : customisable)
{
emailMappingKeyService.makeCustomisable(customEmailMappingKey);
}
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.email;
import java.util.List;
/**
* EMail Mapping Key Service
*
* @author Tuna Aksoy
* @since @2.1
*/
public interface EmailMappingKeyService
{
/**
* Gets the list of email mapping keys
*
* @return Email mapping keys
*/
public List<String> getEmailMappingKeys();
/**
* Makes a email mapping key customisable.
*
* @param emailMappingKey emailMappingKey to make customisable
*/
public void makeCustomisable(String emailMappingKey);
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.email;
import java.util.List;
import org.alfresco.util.ParameterCheck;
/**
* EMail Mapping Key Service
*
* @author Tuna Aksoy
* @since 2.1
*/
public class EmailMappingKeyServiceImpl implements EmailMappingKeyService
{
List<String> emailMappingKeys;
public void setEmailMappingKeys(List<String> emailMappingKeys)
{
this.emailMappingKeys = emailMappingKeys;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getEmailMappingKeys()
*/
@Override
public List<String> getEmailMappingKeys()
{
return emailMappingKeys;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService#makeCustomisable(java.lang.String)
*/
@Override
public void makeCustomisable(String emailMappingKey)
{
ParameterCheck.mandatoryString("emailMappingKey", emailMappingKey);
emailMappingKeys.add(emailMappingKey);
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.script;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Implementation for Java backed webscript to return email mapping keys
*
* @author Tuna Aksoy
* @since 2.1
*/
public class EmailMapKeysGet extends DeclarativeWebScript
{
/** Email mapping key service */
private EmailMappingKeyService emailMappingKeyService;
/**
* Email mapping key service
*
* @param emailMappingKeyService the email mapping key service
*/
public void setEmailMappingKeyService(EmailMappingKeyService emailMappingKeyService)
{
this.emailMappingKeyService = emailMappingKeyService;
}
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
// Create model object with the lists of email mapping keys
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("emailmapkeys", emailMappingKeyService.getEmailMappingKeys());
return model;
}
}