Merged methods from the EmailMappingKeyService to CustomEmailMappingService and deleted the EMailMappingKeyService.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@44324 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2012-12-04 16:13:30 +00:00
parent 414fc1a5f3
commit 4b8b65d023
9 changed files with 162 additions and 272 deletions

View File

@@ -116,7 +116,7 @@
abstract="true" abstract="true"
class="org.alfresco.module.org_alfresco_module_rm.email.CustomisableEmailMappingKeyBootstrap" class="org.alfresco.module.org_alfresco_module_rm.email.CustomisableEmailMappingKeyBootstrap"
init-method="init"> init-method="init">
<property name="emailMappingKeyService" ref="emailMappingKeyService"/> <property name="customEmailMappingService" ref="customEmailMappingService"/>
</bean> </bean>
<bean id="customEmailMappingKey" <bean id="customEmailMappingKey"

View File

@@ -424,8 +424,8 @@
<property name="permissionService" ref="PermissionService"/> <property name="permissionService" ref="PermissionService"/>
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="policyComponent" ref="policyComponent"/> <property name="policyComponent" ref="policyComponent"/>
<property name="recordsManagementService" ref="RecordsManagementService"/> <property name="recordsManagementService" ref="RecordsManagementService"/>
<property name="modelSecurityService" ref="modelSecurityService" /> <property name="modelSecurityService" ref="modelSecurityService" />
</bean> </bean>
<bean id="RecordsManagementSecurityService" class="org.springframework.aop.framework.ProxyFactoryBean"> <bean id="RecordsManagementSecurityService" class="org.springframework.aop.framework.ProxyFactoryBean">
@@ -544,20 +544,20 @@
</value> </value>
</property> </property>
</bean> </bean>
<!-- Model Security service --> <!-- Model Security service -->
<bean id="modelSecurityService" <bean id="modelSecurityService"
class="org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityServiceImpl" class="org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityServiceImpl"
init-method="init"> init-method="init">
<property name="enabled" value="false" /> <property name="enabled" value="false" />
<property name="policyComponent" ref="policyComponent" /> <property name="policyComponent" ref="policyComponent" />
<property name="nodeService" ref="NodeService" /> <property name="nodeService" ref="NodeService" />
<property name="namespaceService" ref="namespaceService" /> <property name="namespaceService" ref="namespaceService" />
<property name="securityService" ref="RecordsManagementSecurityService" /> <property name="securityService" ref="RecordsManagementSecurityService" />
<property name="recordsManagementService" ref="RecordsManagementService" /> <property name="recordsManagementService" ref="RecordsManagementService" />
</bean> </bean>
<bean id="ModelSecurityService" class="org.springframework.aop.framework.ProxyFactoryBean"> <bean id="ModelSecurityService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"> <property name="proxyInterfaces">
<value>org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService</value> <value>org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService</value>
@@ -597,13 +597,13 @@
</property> </property>
<property name="objectDefinitionSource"> <property name="objectDefinitionSource">
<value> <value>
<![CDATA[ <![CDATA[
org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService.*=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService.*=RM_ALLOW
]]> ]]>
</value> </value>
</property> </property>
</bean> </bean>
<!-- Records Management Action Service --> <!-- Records Management Action Service -->
<bean id="recordsManagementActionService" class="org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionServiceImpl" init-method="init"> <bean id="recordsManagementActionService" class="org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionServiceImpl" init-method="init">
@@ -793,10 +793,10 @@
<![CDATA[ <![CDATA[
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.initialiseCustomModel=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.initialiseCustomModel=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.getCustomisable=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.getCustomisable=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.isCustomisable=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.isCustomisable=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.makeCustomisable=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.makeCustomisable=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.unmakeCustomisable=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.unmakeCustomisable=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.existsCustomProperty=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.existsCustomProperty=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.getCustomPropertyDefinitions=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.getCustomPropertyDefinitions=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.addCustomPropertyDefinition=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.addCustomPropertyDefinition=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.updateCustomPropertyDefinitionName=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService.updateCustomPropertyDefinitionName=RM_ALLOW
@@ -1038,7 +1038,16 @@
</property> </property>
<property name="policyComponent"><ref bean="policyComponent" /></property> <property name="policyComponent"><ref bean="policyComponent" /></property>
<property name="transactionService"><ref bean="transactionService" /></property> <property name="transactionService"><ref bean="transactionService" /></property>
<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>
@@ -1069,6 +1078,7 @@
org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.getCustomMappings=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.getCustomMappings=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.addCustomMapping=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.addCustomMapping=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.deleteCustomMapping=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.deleteCustomMapping=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.getEmailMappingKeys=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.*=RM_DENY org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService.*=RM_DENY
]]> ]]>
</value> </value>
@@ -1094,71 +1104,6 @@
</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

@@ -501,6 +501,6 @@
<bean id="webscript.org.alfresco.rma.admin.emailmapkeys.get" <bean id="webscript.org.alfresco.rma.admin.emailmapkeys.get"
class="org.alfresco.module.org_alfresco_module_rm.script.EmailMapKeysGet" class="org.alfresco.module.org_alfresco_module_rm.script.EmailMapKeysGet"
parent="webscript"> parent="webscript">
<property name="emailMappingKeyService" ref="EmailMappingKeyService" /> <property name="customEmailMappingService" ref="CustomEmailMappingService" />
</bean> </bean>
</beans> </beans>

View File

@@ -18,6 +18,7 @@
*/ */
package org.alfresco.module.org_alfresco_module_rm.email; package org.alfresco.module.org_alfresco_module_rm.email;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@@ -27,24 +28,38 @@ public interface CustomEmailMappingService
{ {
/** /**
* Get the list of custom mappings * Get the list of custom mappings
* *
* @return {@link Set}<{@link CustomMapping}> * @return {@link Set}<{@link CustomMapping}>
*/ */
public Set<CustomMapping> getCustomMappings(); public Set<CustomMapping> getCustomMappings();
/** /**
* Add custom mapping * Add custom mapping
* *
* @param from * @param from
* @param to * @param to
*/ */
public void addCustomMapping(String from, String to); public void addCustomMapping(String from, String to);
/** /**
* Delete custom mapping * Delete custom mapping
* *
* @param from * @param from
* @param to * @param to
*/ */
public void deleteCustomMapping(String from, String to); public void deleteCustomMapping(String from, String to);
/**
* Gets the list of email mapping keys
*
* @return Email mapping keys
*/
public List<String> getEmailMappingKeys();
/**
* Registers an email mapping key with the existing list of email mapping keys
*
* @param emailMappingKey emailMappingKey to register
*/
public void registerEMailMappingKey(String emailMappingKey);
} }

View File

@@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.email;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -43,6 +44,7 @@ import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ParameterCheck;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONArray; import org.json.JSONArray;
@@ -58,28 +60,28 @@ import org.springframework.extensions.surf.util.AbstractLifecycleBean;
public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean implements CustomEmailMappingService public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean implements CustomEmailMappingService
{ {
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(CustomEmailMappingServiceImpl.class); private static Log logger = LogFactory.getLog(CustomEmailMappingServiceImpl.class);
/** Node reference's to configuration elements */ /** Node reference's to configuration elements */
private static final NodeRef CONFIG_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_emailmapping_config"); private static final NodeRef CONFIG_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_emailmapping_config");
private static final NodeRef CONFIG_FOLDER_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder"); private static final NodeRef CONFIG_FOLDER_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder");
/** Config file name */ /** Config file name */
private static final String CONFIG_NAME = "imapConfig.json"; private static final String CONFIG_NAME = "imapConfig.json";
/** Default custom mappings (TODO move to spring config) */ /** Default custom mappings (TODO move to spring config) */
private static final CustomMapping[] DEFAULT_MAPPINGS = private static final CustomMapping[] DEFAULT_MAPPINGS =
{ {
new CustomMapping("Date", "rma:dateReceived"), new CustomMapping("Date", "rma:dateReceived"),
new CustomMapping("messageTo", "rma:address"), new CustomMapping("messageTo", "rma:address"),
new CustomMapping("messageFrom", "rma:originator"), new CustomMapping("messageFrom", "rma:originator"),
new CustomMapping("messageSent", "rma:publicationDate"), new CustomMapping("messageSent", "rma:publicationDate"),
new CustomMapping("messageCc", "rma:otherAddress") new CustomMapping("messageCc", "rma:otherAddress")
}; };
/** Extractor */ /** Extractor */
private RFC822MetadataExtracter extracter; private RFC822MetadataExtracter extracter;
/** Services */ /** Services */
private NodeService nodeService; private NodeService nodeService;
private NamespacePrefixResolver nspr; private NamespacePrefixResolver nspr;
@@ -87,10 +89,13 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
private ContentService contentService; private ContentService contentService;
private TransactionService transactionService; private TransactionService transactionService;
/** Transient set of custom mappings */ /** Transient set of custom mappings */
private Set<CustomMapping> customMappings; private Set<CustomMapping> customMappings;
/** List of email mapping keys */
private List<String> emailMappingKeys;
/** /**
* @param policyComponent policy component * @param policyComponent policy component
*/ */
@@ -138,7 +143,15 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
{ {
this.transactionService = transactionService; this.transactionService = transactionService;
} }
/**
* @param emailMappingKeys email mapping keys
*/
public void setEmailMappingKeys(List<String> emailMappingKeys)
{
this.emailMappingKeys = emailMappingKeys;
}
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getCustomMappings() * @see org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService#getCustomMappings()
*/ */
@@ -154,24 +167,24 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
} }
else else
{ {
customMappings = new HashSet<CustomMapping>(); customMappings = new HashSet<CustomMapping>();
// load the contents of the extractors property file // load the contents of the extractors property file
Map<String, Set<QName>> currentMapping = extracter.getCurrentMapping(); Map<String, Set<QName>> currentMapping = extracter.getCurrentMapping();
for(String key : currentMapping.keySet()) for(String key : currentMapping.keySet())
{ {
Set<QName> set = currentMapping.get(key); Set<QName> set = currentMapping.get(key);
for(QName qname : set) for(QName qname : set)
{ {
CustomMapping value = new CustomMapping(); CustomMapping value = new CustomMapping();
value.setFrom(key); value.setFrom(key);
QName resolvedQname = qname.getPrefixedQName(nspr); QName resolvedQname = qname.getPrefixedQName(nspr);
value.setTo(resolvedQname.toPrefixString()); value.setTo(resolvedQname.toPrefixString());
customMappings.add(value); customMappings.add(value);
} }
} }
// if we have an old config file // if we have an old config file
NodeRef oldConfigNode = getOldConfigNode(); NodeRef oldConfigNode = getOldConfigNode();
if (oldConfigNode != null) if (oldConfigNode != null)
@@ -180,18 +193,18 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
Set<CustomMapping> oldMappings = readOldConfig(oldConfigNode); Set<CustomMapping> oldMappings = readOldConfig(oldConfigNode);
customMappings.addAll(oldMappings); customMappings.addAll(oldMappings);
} }
// load the hard coded mappings // load the hard coded mappings
for(CustomMapping mapping : DEFAULT_MAPPINGS) for(CustomMapping mapping : DEFAULT_MAPPINGS)
{ {
customMappings.add(mapping); customMappings.add(mapping);
} }
// create the config file // create the config file
saveConfig(customMappings); saveConfig(customMappings);
} }
} }
return customMappings; return customMappings;
} }
@@ -200,23 +213,23 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
*/ */
public void addCustomMapping(String from, String to) public void addCustomMapping(String from, String to)
{ {
// create custom mapping // create custom mapping
CustomMapping customMapping = new CustomMapping(from, to); CustomMapping customMapping = new CustomMapping(from, to);
// check whether we already have this mapping or not // check whether we already have this mapping or not
Set<CustomMapping> customMappings = getCustomMappings(); Set<CustomMapping> customMappings = getCustomMappings();
if (customMappings.contains(customMapping) == true) if (customMappings.contains(customMapping) == true)
{ {
throw new AlfrescoRuntimeException("Can not add custom email mapping, because duplicate mapping already exists."); throw new AlfrescoRuntimeException("Can not add custom email mapping, because duplicate mapping already exists.");
} }
// else add the custom mapping (since we have already called getCustomMapping we can be sure // else add the custom mapping (since we have already called getCustomMapping we can be sure
// the member variable is populated) // the member variable is populated)
customMappings.add(customMapping); customMappings.add(customMapping);
// save the changes into the config file // save the changes into the config file
saveConfig(customMappings); saveConfig(customMappings);
// update the extractors configuration // update the extractors configuration
updateExtractor(); updateExtractor();
} }
@@ -226,32 +239,52 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
*/ */
public void deleteCustomMapping(String from, String to) public void deleteCustomMapping(String from, String to)
{ {
// create custom mapping // create custom mapping
CustomMapping customMapping = new CustomMapping(from, to); CustomMapping customMapping = new CustomMapping(from, to);
// check whether we already have this mapping or not // check whether we already have this mapping or not
Set<CustomMapping> customMappings = getCustomMappings(); Set<CustomMapping> customMappings = getCustomMappings();
if (customMappings.contains(customMapping) == true) if (customMappings.contains(customMapping) == true)
{ {
// else remove the custom mapping (since we have already called getCustomMapping we can be sure // else remove the custom mapping (since we have already called getCustomMapping we can be sure
// the member variable is populated) // the member variable is populated)
customMappings.remove(customMapping); customMappings.remove(customMapping);
// save the changes into the config file // save the changes into the config file
saveConfig(customMappings); saveConfig(customMappings);
// update the extractors configuration // update the extractors configuration
updateExtractor(); updateExtractor();
} }
} }
/**
* @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#registerEMailMappingKey(java.lang.String)
*/
@Override
public void registerEMailMappingKey(String emailMappingKey)
{
ParameterCheck.mandatoryString("emailMappingKey", emailMappingKey);
emailMappingKeys.add(emailMappingKey);
}
/** /**
* Updates the extractor with the custom configuration. * Updates the extractor with the custom configuration.
*/ */
private void updateExtractor() private void updateExtractor()
{ {
// convert the mapping information into the form understood by the extractor // convert the mapping information into the form understood by the extractor
Map<String, Set<QName>> newMapping = new HashMap<String, Set<QName>>(17); Map<String, Set<QName>> newMapping = new HashMap<String, Set<QName>>(17);
for(CustomMapping mapping : getCustomMappings()) for(CustomMapping mapping : getCustomMappings())
{ {
QName newQName = QName.createQName(mapping.getTo(), nspr); QName newQName = QName.createQName(mapping.getTo(), nspr);
@@ -265,13 +298,13 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
} }
// update the metadata extracter // update the metadata extracter
extracter.setMapping(newMapping); extracter.setMapping(newMapping);
} }
/** /**
* Loads the custom mappings from the configuration file. * Loads the custom mappings from the configuration file.
* *
* @return * @return
*/ */
private Set<CustomMapping> loadConfig() private Set<CustomMapping> loadConfig()
{ {
@@ -280,9 +313,9 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
if (cr != null) if (cr != null)
{ {
String text = cr.getContentString(); String text = cr.getContentString();
try try
{ {
JSONArray jsonArray = new JSONArray(new JSONTokener(text)); JSONArray jsonArray = new JSONArray(new JSONTokener(text));
for(int i = 0 ; i < jsonArray.length(); i++) for(int i = 0 ; i < jsonArray.length(); i++)
{ {
@@ -296,14 +329,14 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
catch (JSONException je) catch (JSONException je)
{ {
throw new AlfrescoRuntimeException("Unable to read custom email configuration", je); throw new AlfrescoRuntimeException("Unable to read custom email configuration", je);
} }
} }
return result; return result;
} }
/** /**
* *
* @param customMappingsToSave * @param customMappingsToSave
*/ */
private void saveConfig(Set<CustomMapping> customMappingsToSave) private void saveConfig(Set<CustomMapping> customMappingsToSave)
@@ -315,13 +348,13 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
properties.put(ContentModel.PROP_NAME, CONFIG_NAME); properties.put(ContentModel.PROP_NAME, CONFIG_NAME);
properties.put(ContentModel.PROP_NODE_UUID, CONFIG_NODE_REF.getId()); properties.put(ContentModel.PROP_NODE_UUID, CONFIG_NODE_REF.getId());
nodeService.createNode( nodeService.createNode(
CONFIG_FOLDER_NODE_REF, CONFIG_FOLDER_NODE_REF,
ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, CONFIG_NAME), QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, CONFIG_NAME),
ContentModel.TYPE_CONTENT, ContentModel.TYPE_CONTENT,
properties); properties);
} }
// build JSON array of mappings // build JSON array of mappings
JSONArray jsonMappings = new JSONArray(); JSONArray jsonMappings = new JSONArray();
try try
@@ -338,14 +371,14 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
{ {
throw new AlfrescoRuntimeException("Unable to create JSON email mapping configuration during save.", je); throw new AlfrescoRuntimeException("Unable to create JSON email mapping configuration during save.", je);
} }
// update the content // update the content
ContentWriter writer = this.contentService.getWriter(CONFIG_NODE_REF, ContentModel.PROP_CONTENT, true); ContentWriter writer = this.contentService.getWriter(CONFIG_NODE_REF, ContentModel.PROP_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.setEncoding("UTF-8"); writer.setEncoding("UTF-8");
writer.putContent(jsonMappings.toString()); writer.putContent(jsonMappings.toString());
} }
/** /**
* @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent) * @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
*/ */
@@ -373,10 +406,10 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
{ {
logger.warn(e.getMessage()); logger.warn(e.getMessage());
} }
// reset the mappings // reset the mappings
customMappings = null; customMappings = null;
// rethrow // rethrow
throw e; throw e;
} }
@@ -384,7 +417,7 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
} }
}; };
transactionService.getRetryingTransactionHelper().doInTransaction(callback); transactionService.getRetryingTransactionHelper().doInTransaction(callback);
return null; return null;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
@@ -398,13 +431,13 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
{ {
// No implementation // No implementation
} }
/** /**
* Helper method to get the old configuration node. This is used during the migration * Helper method to get the old configuration node. This is used during the migration
* from 1.0 to 2.0. * from 1.0 to 2.0.
* <p> * <p>
* Returns null if it does not exist. * Returns null if it does not exist.
* *
* @return {@link NodeRef} node reference of the old configuration node, null otherwise * @return {@link NodeRef} node reference of the old configuration node, null otherwise
*/ */
private NodeRef getOldConfigNode() private NodeRef getOldConfigNode()
@@ -412,24 +445,24 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
return nodeService.getChildByName(rootNode, RecordsManagementModel.ASSOC_EMAIL_CONFIG, CONFIG_NAME); return nodeService.getChildByName(rootNode, RecordsManagementModel.ASSOC_EMAIL_CONFIG, CONFIG_NAME);
} }
/** /**
* Reads the old configuration node. This is used during the migration from 1.0 to 2.0. * Reads the old configuration node. This is used during the migration from 1.0 to 2.0.
* *
* @param nodeRef the old configuration node reference * @param nodeRef the old configuration node reference
* @return {@link Set}<{@link CustomMapping}> set of the custom mappings stored in the old configuration * @return {@link Set}<{@link CustomMapping}> set of the custom mappings stored in the old configuration
*/ */
private Set<CustomMapping> readOldConfig(NodeRef nodeRef) private Set<CustomMapping> readOldConfig(NodeRef nodeRef)
{ {
Set<CustomMapping> newMappings = new HashSet<CustomMapping>(); Set<CustomMapping> newMappings = new HashSet<CustomMapping>();
ContentReader cr = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); ContentReader cr = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
if (cr != null) if (cr != null)
{ {
String text = cr.getContentString(); String text = cr.getContentString();
try try
{ {
JSONArray jsonArray = new JSONArray(new JSONTokener(text)); JSONArray jsonArray = new JSONArray(new JSONTokener(text));
for(int i = 0 ; i < jsonArray.length(); i++) for(int i = 0 ; i < jsonArray.length(); i++)
{ {
@@ -446,8 +479,8 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
logger.warn("unable to read custom email configuration", je); logger.warn("unable to read custom email configuration", je);
return newMappings; return newMappings;
} }
} }
return newMappings; return newMappings;
} }
} }

View File

@@ -31,8 +31,8 @@ public class CustomisableEmailMappingKeyBootstrap
/** List of mappings to register as customisable */ /** List of mappings to register as customisable */
private List<String> customisable; private List<String> customisable;
/** Email mapping key service */ /** Custom email mapping service */
private EmailMappingKeyService emailMappingKeyService; private CustomEmailMappingService customEmailMappingService;
/** /**
* @param customizable list of mappings to register as customisable * @param customizable list of mappings to register as customisable
@@ -43,13 +43,13 @@ public class CustomisableEmailMappingKeyBootstrap
} }
/** /**
* Email mapping key service * Custom email mapping service
* *
* @param emailMappingKeyService the email mapping key service * @param customEmailMappingService the custom email mapping service
*/ */
public void setEmailMappingKeyService(EmailMappingKeyService emailMappingKeyService) public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService)
{ {
this.emailMappingKeyService = emailMappingKeyService; this.customEmailMappingService = customEmailMappingService;
} }
/** /**
@@ -59,7 +59,7 @@ public class CustomisableEmailMappingKeyBootstrap
{ {
for (String customEmailMappingKey : customisable) for (String customEmailMappingKey : customisable)
{ {
emailMappingKeyService.makeCustomisable(customEmailMappingKey); customEmailMappingService.registerEMailMappingKey(customEmailMappingKey);
} }
} }
} }

View File

@@ -1,44 +0,0 @@
/*
* 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

@@ -1,59 +0,0 @@
/*
* 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

@@ -21,7 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.script;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.email.EmailMappingKeyService; import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService;
import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.Status;
@@ -35,17 +35,17 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
*/ */
public class EmailMapKeysGet extends DeclarativeWebScript public class EmailMapKeysGet extends DeclarativeWebScript
{ {
/** Email mapping key service */ /** Custom email mapping service */
private EmailMappingKeyService emailMappingKeyService; private CustomEmailMappingService customEmailMappingService;
/** /**
* Email mapping key service * Custom email mapping service
* *
* @param emailMappingKeyService the email mapping key service * @param customEmailMappingService the custom email mapping service
*/ */
public void setEmailMappingKeyService(EmailMappingKeyService emailMappingKeyService) public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService)
{ {
this.emailMappingKeyService = emailMappingKeyService; this.customEmailMappingService = customEmailMappingService;
} }
@Override @Override
@@ -53,7 +53,7 @@ public class EmailMapKeysGet extends DeclarativeWebScript
{ {
// Create model object with the lists of email mapping keys // Create model object with the lists of email mapping keys
Map<String, Object> model = new HashMap<String, Object>(1); Map<String, Object> model = new HashMap<String, Object>(1);
model.put("emailmapkeys", emailMappingKeyService.getEmailMappingKeys()); model.put("emailmapkeys", customEmailMappingService.getEmailMappingKeys());
return model; return model;
} }
} }