diff --git a/config/alfresco/alfresco-shared.properties b/config/alfresco/alfresco-shared.properties
index 42502b77a7..40d88ffc55 100644
--- a/config/alfresco/alfresco-shared.properties
+++ b/config/alfresco/alfresco-shared.properties
@@ -2,19 +2,12 @@
# Properties shared between the Alfresco server
# and its remote clients (e.g.: the virtualization server).
#
-# Ports used by Alfresco AVM
+# Ports used by Alfresco
#
# Note: These ports are also used by the virtualization server
-# (hence, they're in a seperate file that's can be copied easily).
-
-
-# Name of the host running AVM
-avm.remote.host=localhost
-
-# AVMRemote API
-avm.remote.port=50500
+# (hence, they're in a seperate file that can be copied easily).
# Remote RMI services
-rmi.services.remote.port=${avm.remote.port}
-rmi.services.remote.host=${avm.remote.host}
+alfresco.rmi.services.port=50500
+alfresco.rmi.services.host=localhost
diff --git a/config/alfresco/application-context.xml b/config/alfresco/application-context.xml
index 9f5483131c..7b17e237bf 100644
--- a/config/alfresco/application-context.xml
+++ b/config/alfresco/application-context.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index cbd185cf06..06ab618468 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -100,6 +100,10 @@
/${alfresco_user_store.system_container.childname}
alfresco/bootstrap/alfrescoAuthorityStorePermission.xml
+
+ /${alfresco_user_store.system_container.childname}/sys:authorities
+ alfresco/bootstrap/emailServer.xml
+
@@ -432,12 +436,25 @@
-
diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml
index 605a21dcb6..e1e96ac459 100644
--- a/config/alfresco/core-services-context.xml
+++ b/config/alfresco/core-services-context.xml
@@ -55,7 +55,7 @@
-
+
@@ -65,7 +65,7 @@
-
+
-
true
- classpath:alfresco/email-server.properties
+ classpath:alfresco/emailserver/email-server.properties
-
-
-
- ${email.server.domain}
-
-
-
- ${email.server.port}
-
-
-
- ${email.server.enabled}
-
-
-
- ${email.server.blocked.senders}
-
-
-
- ${email.server.allowed.senders}
-
-
-
-
-
-
-
@@ -60,55 +32,74 @@
org.alfresco.service.cmr.email.EmailService
- emailService
+ EmailService
- ${avm.remote.port}
+ ${alfresco.rmi.services.port}
+
+
-
-
- ${mail.inbound.enabled}
+
+ ${email.inbound.enabled}
+
+
+ ${email.inbound.unknownUser}
-
-
-
-
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -162,5 +132,4 @@
-
diff --git a/config/alfresco/extension/bm-remote-loader-context.xml.sample b/config/alfresco/extension/bm-remote-loader-context.xml.sample
index 83df9e444c..69aa98ef56 100644
--- a/config/alfresco/extension/bm-remote-loader-context.xml.sample
+++ b/config/alfresco/extension/bm-remote-loader-context.xml.sample
@@ -32,7 +32,7 @@
org.alfresco.FileFolderRemote
- ${rmi.services.remote.port}
+ ${alfresco.rmi.services.port}
@@ -70,7 +70,7 @@
org.alfresco.LoaderRemote
- ${rmi.services.remote.port}
+ ${alfresco.rmi.services.port}
diff --git a/config/alfresco/extension/custom-email-server.sample.zip b/config/alfresco/extension/custom-email-server.sample.zip
new file mode 100644
index 0000000000..806fee01af
Binary files /dev/null and b/config/alfresco/extension/custom-email-server.sample.zip differ
diff --git a/config/alfresco/messages/email-service.properties b/config/alfresco/messages/email-service.properties
index ab7f00eaa4..a2b66e2f8e 100644
--- a/config/alfresco/messages/email-service.properties
+++ b/config/alfresco/messages/email-service.properties
@@ -1,17 +1,24 @@
-email.server.denied-address="Address {0} is in black list"
-email.server.not-white-address="Address {0} is not in white list"
-email.server.incorrect-node-ref="Incorrect node ref"
-email.server.incorrect-node-address="Incorrect node address"
-email.server.incorrect-node-type="Incorrect node type"
-email.server.handler-not-found="Hanlder wasn't found"
-email.server.unknown-user="Unknown user is not in email contribute group"
-email.server.not-contribute-user="User {0} is not in contribute group"
-email.server.contribute-group-not-exist="Email contribute group is not created"
-email.server.content-error="Content error"
-email.server.incorrect-message-part="Incorrect message part"
-email.server.error-getting-message-content="Couldn't get message part content"
-email.server.error-getting-content-stream="Couldn't get stream of the message part content"
-email.server.error-creating-message="Couldn't create MIME message from input stream"
-email.server.error-parse-message="Couldn't parse the message"
-email.server.mail-inbound-disabled="Email behaviour to be disabled completely on the server"
-email.server.usupported-encoding="Encoding {0} is not support"
\ No newline at end of file
+email.server.msg.received_by_smtp=Received by SMTP from ''{0}''.
+email.server.msg.default_subject=Email-{0}
+
+email.server.err.sender_blocked=''{0}'' has been denied access.
+email.server.err.inbound_mail_disabled=The Alfresco server is not configured to accept inbound emails.
+email.server.err.access_denied=''{0}'' has been denied access to ''{1}''.
+email.server.err.invalid_subject=The subject line must be a valid file name.
+email.server.err.unknown_source_address=The 'from' email address was not recognised: {0}.
+email.server.err.user_not_email_contributor=The user ''{0}'' in not in the email contributor group.
+email.server.err.no_email_contributor_group=The Email Contributor Group doesn't exist.
+email.server.err.invalid_node_address=The email address ''{0}'' does not reference a valid accessible node.
+email.server.err.handler_not_found=Email message handler was not found for node type ''{0}''.
+email.server.err.mail_read_error=An error occured while reading the mail message: {0}
+email.server.err.failed_to_create_mime_message=Failed to create MIME message from input stream: {0}
+email.server.err.extracting_from_address=Failed to extract the 'from' address: {0}
+email.server.err.no_from_address=The message has no 'from' address.
+email.server.err.extracting_to_address=Failed to extract the 'to' address: {0}
+email.server.err.no_to_address=The message has no 'to' address.
+email.server.err.extracting_subject=Failed to extract the message subject: {0}
+email.server.err.extracting_sent_date=Failed to extract the 'sent on' date: {0}
+email.server.err.parse_message=Failed to parse the email message: {0}
+email.server.err.usupported_encoding=Encoding ''{0}'' is not supported
+email.server.err.failed_to_read_content_stream=Failed to read the message part content: {0}
+email.server.err.incorrect_message_part=Incorrect message part: {0}
diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties
index cc0251fb47..2886f3e156 100644
--- a/config/alfresco/messages/patch-service.properties
+++ b/config/alfresco/messages/patch-service.properties
@@ -177,3 +177,5 @@ patch.customMessages.description=Adds Messages space to Data Dictionary.
patch.customWebClientExtension.description=Adds Web Client Extension space to Data Dictionary.
patch.customWorkflowDefs.description=Adds Workflow Definitions space to Data Dictionary.
+
+patch.emailContributorGroup.description=Adds the 'GROUP_EMAIL_CONTRIBUTORS' group.
diff --git a/config/alfresco/model/emailServerModel.xml b/config/alfresco/model/emailServerModel.xml
index 721f67ba4e..54ed5516d0 100644
--- a/config/alfresco/model/emailServerModel.xml
+++ b/config/alfresco/model/emailServerModel.xml
@@ -25,6 +25,13 @@
prefix="emailserver" />
+
+
+
+ true
+
+
+
@@ -51,12 +58,15 @@
- Aliasable
+ Email Alias
Alias
d:text
true
+
+
+
diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml
index dca8aef4fe..0e6315ab66 100644
--- a/config/alfresco/patch/patch-services-context.xml
+++ b/config/alfresco/patch/patch-services-context.xml
@@ -1037,5 +1037,26 @@
+
+
+ patch.emailContributorGroup
+ patch.emailContributorGroup.description
+ 0
+ 108
+ 109
+
+
+
+
+
+ /${alfresco_user_store.system_container.childname}/sys:authorities/usr:GROUP_EMAIL_CONTRIBUTORS
+
+
+
+ /${alfresco_user_store.system_container.childname}/sys:authorities
+ alfresco/bootstrap/emailServer.xml
+
+
+
diff --git a/config/alfresco/remote-services-context.xml b/config/alfresco/remote-services-context.xml
index cabf719b74..b459942f63 100644
--- a/config/alfresco/remote-services-context.xml
+++ b/config/alfresco/remote-services-context.xml
@@ -29,7 +29,7 @@
avm
- ${avm.remote.port}
+ ${alfresco.rmi.services.port}
@@ -53,7 +53,7 @@
avmsync
- ${avm.remote.port}
+ ${alfresco.rmi.services.port}
@@ -78,7 +78,7 @@
attributes
- ${avm.remote.port}
+ ${alfresco.rmi.services.port}
@@ -94,7 +94,7 @@
authentication
- ${avm.remote.port}
+ ${alfresco.rmi.services.port}
@@ -161,7 +161,7 @@
repo
- ${avm.remote.port}
+ ${alfresco.rmi.services.port}
@@ -187,7 +187,7 @@
action
- ${avm.remote.port}
+ ${alfresco.rmi.services.port}
\ No newline at end of file
diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties
index 31aec46bb6..f4856caa1e 100644
--- a/config/alfresco/version.properties
+++ b/config/alfresco/version.properties
@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number
-version.schema=108
+version.schema=109
diff --git a/source/java/org/alfresco/email/server/AliasableAspect.java b/source/java/org/alfresco/email/server/AliasableAspect.java
index a2feb26b34..1c33eaaf88 100644
--- a/source/java/org/alfresco/email/server/AliasableAspect.java
+++ b/source/java/org/alfresco/email/server/AliasableAspect.java
@@ -54,8 +54,9 @@ public class AliasableAspect implements NodeServicePolicies.OnAddAspectPolicy, N
private SearchService searchService;
- public static final String SEARCH_TEMPLATE = "ASPECT:\"" + EmailServerModel.ASPECT_ALIASABLE + "\" +@" + NamespaceService.EMAILSERVER_MODEL_PREFIX + "\\:"
- + EmailServerModel.PROP_ALIAS.getLocalName() + ":\"%s\"";
+ public static final String SEARCH_TEMPLATE =
+ "ASPECT:\"" + EmailServerModel.ASPECT_ALIASABLE +
+ "\" +@" + NamespaceService.EMAILSERVER_MODEL_PREFIX + "\\:" + EmailServerModel.PROP_ALIAS.getLocalName() + ":\"%s\"";
/**
* @param searchService Alfresco Search Service
diff --git a/source/java/org/alfresco/email/server/EmailServer.java b/source/java/org/alfresco/email/server/EmailServer.java
index 60ec4767f0..40331c155d 100644
--- a/source/java/org/alfresco/email/server/EmailServer.java
+++ b/source/java/org/alfresco/email/server/EmailServer.java
@@ -24,9 +24,16 @@
*/
package org.alfresco.email.server;
-import org.alfresco.i18n.I18NUtil;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.email.EmailMessageException;
+import org.alfresco.service.cmr.email.EmailService;
import org.alfresco.util.AbstractLifecycleBean;
+import org.alfresco.util.PropertyCheck;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.AbstractApplicationContext;
@@ -38,61 +45,162 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public abstract class EmailServer extends AbstractLifecycleBean
{
- protected EmailServerConfiguration configuration;
+ private static final String ERR_SENDER_BLOCKED = "email.server.err.sender_blocked";
+
+ private boolean enabled;
+ private String domain;
+ private int port;
+ private Set blockedSenders;
+ private Set allowedSenders;
+
+ private EmailService emailService;
+
/**
* @param serverConfiguration Server configuration
*/
- protected EmailServer(EmailServerConfiguration serverConfiguration)
+ protected EmailServer()
{
- this.configuration = serverConfiguration;
+ this.enabled = false;
+ this.port = 25;
+ this.domain = null;
+ this.blockedSenders = new HashSet(23);
+ this.allowedSenders = new HashSet(23);
+ }
+
+ /**
+ * @param enabled Enable/disable server
+ */
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ protected String getDomain()
+ {
+ return domain;
+ }
+
+ public void setDomain(String domain)
+ {
+ this.domain = domain;
+ }
+
+ protected int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * @param port SMTP port (25 is default)
+ */
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
+
+ /**
+ * Set the blocked senders as a comma separated list. The entries will be trimmed of
+ * all whitespace.
+ *
+ * @param blockedSenders a comman separated list of blocked senders
+ */
+ public void setBlockedSenders(String blockedSenders)
+ {
+ StringTokenizer tokenizer = new StringTokenizer(blockedSenders, ",", false);
+ while (tokenizer.hasMoreTokens())
+ {
+ String sender = tokenizer.nextToken().trim();
+ this.blockedSenders.add(sender);
+ }
+ }
+
+ /**
+ * @param blockedSenders a list of senders that are not allowed to email in
+ */
+ public void setBlockedSenders(List blockedSenders)
+ {
+ this.blockedSenders.addAll(blockedSenders);
+ }
+
+ /**
+ * Set the allowed senders as a comma separated list. The entries will be trimmed of
+ * all whitespace.
+ *
+ * @param allowedSenders a comman separated list of blocked senders
+ */
+ public void setAllowedSenders(String allowedSenders)
+ {
+ StringTokenizer tokenizer = new StringTokenizer(allowedSenders, ",", false);
+ while (tokenizer.hasMoreTokens())
+ {
+ String sender = tokenizer.nextToken().trim();
+ if (sender.length() == 0)
+ {
+ // Nothing
+ continue;
+ }
+ this.allowedSenders.add(sender);
+ }
+ }
+
+ /**
+ * @param allowedSenders a list of senders that are allowed to email in
+ */
+ public void setAllowedSenders(List allowedSenders)
+ {
+ this.allowedSenders.addAll(allowedSenders);
+ }
+
+ /**
+ * @return the service interface to interact with
+ */
+ protected EmailService getEmailService()
+ {
+ return emailService;
+ }
+
+ /**
+ * @param emailService the service interface to interact with
+ */
+ public void setEmailService(EmailService emailService)
+ {
+ this.emailService = emailService;
}
/**
* Filter incoming message by its sender e-mail address.
*
- * @param sender An e-mail address of sender
- * @throws EmailMessageException Exception will be thrown if the e-mail is rejected accordingly with blocked and allowed lists.
+ * @param sender An e-mail address of sender
+ * @throws EmailMessageException if the e-mail is rejected accordingly with blocked and allowed lists
*/
- public void blackAndWhiteListFiltering(String sender)
+ protected void filterSender(String sender)
{
- // At first try to find sender in the black list
- String[] blackList = configuration.getArrayBlockedSenders();
- String[] whiteList = configuration.getArrayAllowedSenders();
-
- // At first try to find sender in the black list
- // If sender is found, mail will be rejected at once
- if (blackList != null)
+ // Check if the sender is in the blocked list
+ for (String blockedSender : blockedSenders)
{
- for (String deniedAddress : blackList)
+ if (sender.matches(blockedSender))
{
- if (sender.matches(deniedAddress))
- {
- throw new EmailMessageException(I18NUtil.getMessage("email.server.denied-address", sender));
- }
+ throw new EmailMessageException(ERR_SENDER_BLOCKED, sender);
}
}
-
- // Sender wasn't found in black list or black list is empty
- // Try to find sender in the white list
- // If sender is found in white list,
- // the message will be accepted at once.
- if (whiteList != null)
+
+ // If there are any restrictions in the allowed list, then a positive match
+ // is absolutely required
+ if (!allowedSenders.isEmpty())
{
- boolean accept = false;
- for (String acceptedAddress : whiteList)
+ boolean matched = false;
+ for (String allowedSender : allowedSenders)
{
- if (sender.matches(acceptedAddress))
+ if (sender.matches(allowedSender))
{
- if (log.isInfoEnabled())
- log.info("Sender with address \"" + sender + "\"matches to expression \"" + acceptedAddress + "\" in the white list. The message was accepted.");
- accept = true;
+ matched = true;
break;
}
}
- if (!accept)
+ if (!matched)
{
- throw new EmailMessageException(I18NUtil.getMessage("email.server.not-white-address", sender));
+ throw new EmailMessageException(ERR_SENDER_BLOCKED, sender);
}
}
}
@@ -113,10 +221,19 @@ public abstract class EmailServer extends AbstractLifecycleBean
@Override
protected void onBootstrap(ApplicationEvent event)
{
- if (configuration.isEnabled())
+ if (!enabled)
{
- startup();
+ return;
}
+ // Check properties
+ PropertyCheck.mandatory(this, "domain", domain);
+ if (port <= 0 || port > 65535)
+ {
+ throw new AlfrescoRuntimeException("Property 'port' is incorrect");
+ }
+ PropertyCheck.mandatory(this, "emailService", emailService);
+ // Startup
+ startup();
}
/**
@@ -125,7 +242,7 @@ public abstract class EmailServer extends AbstractLifecycleBean
@Override
protected void onShutdown(ApplicationEvent event)
{
- if (configuration.isEnabled())
+ if (enabled)
{
shutdown();
}
diff --git a/source/java/org/alfresco/email/server/EmailServerConfiguration.java b/source/java/org/alfresco/email/server/EmailServerConfiguration.java
deleted file mode 100644
index d6afa2800d..0000000000
--- a/source/java/org/alfresco/email/server/EmailServerConfiguration.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.email.server;
-
-import org.alfresco.error.AlfrescoRuntimeException;
-import org.alfresco.service.cmr.email.EmailService;
-import org.alfresco.util.AbstractLifecycleBean;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.context.ApplicationEvent;
-
-/**
- * Encapsulation of setting controlling the email server.
- * @since 2.2
- */
-public class EmailServerConfiguration extends AbstractLifecycleBean
-{
- private final static Log log = LogFactory.getLog(EmailServerConfiguration.class);
-
- private boolean enabled = false;
-
- private String domain;
- private int port = 25;
-
- private String[] blockedSenders;
- private String[] allowedSenders;
-
- private EmailService emailService;
-
- /**
- * @return True if server is enabled.
- */
- public boolean isEnabled()
- {
- return enabled;
- }
-
- /**
- * @param enabled Enable/disable server
- */
- public void setEnabled(boolean enabled)
- {
- this.enabled = enabled;
- }
-
- /**
- * @return Domain
- */
- public String getDomain()
- {
- return domain;
- }
-
- /**
- * @param domain Domain
- */
- public void setDomain(String domain)
- {
- this.domain = domain;
- }
-
- /**
- * @return SMTP port (25 is default)
- */
- public int getPort()
- {
- return port;
- }
-
- /**
- * @param port SMTP port (25 is default)
- */
- public void setPort(int port)
- {
- this.port = port;
- }
-
- /**
- * @return Array of e-mail addresses. If an incoming e-mail has a sender from this list, message will be rejected.
- */
- public String[] getArrayBlockedSenders()
- {
- return blockedSenders;
- }
-
- /**
- * @param Comma separated blackSenders of e-mail addresses. If an incoming e-mail has a sender from this list, message will be rejected.
- */
- public void setBlockedSenders(String blockedSenders)
- {
- if (blockedSenders != null && blockedSenders.trim().length() > 0)
- {
- this.blockedSenders = blockedSenders.split(";");
- }
- else
- {
- this.blockedSenders = null;
- }
- }
-
- /**
- * @return Array of e-mail addresses. If an incoming e-mail has a sender from this list, message will be accepted.
- */
- public String[] getArrayAllowedSenders()
- {
- return allowedSenders;
- }
-
- /**
- * @param Comma separated whiteSenders of e-mail addresses. If an incoming e-mail has a sender from this list, message will be accepted.
- */
- public void setAllowedSenders(String allowedSenders)
- {
- if (allowedSenders != null && allowedSenders.trim().length() > 0)
- {
- this.allowedSenders = allowedSenders.split(";");
- }
- else
- {
- this.allowedSenders = null;
- }
- }
-
- /**
- * @return Email Service
- */
- public EmailService getEmailService()
- {
- return emailService;
- }
-
- /**
- * @param emailService Email Service
- */
- public void setEmailService(EmailService emailService)
- {
- this.emailService = emailService;
- }
-
- /**
- * Method checks that all mandatory fiedls are set.
- *
- * @throws AlfrescoRuntimeException Exception is thrown if at least one mandatory field isn't set.
- */
- private void check()
- {
- if (domain == null)
- {
- throw new AlfrescoRuntimeException("Property 'domain' not set");
- }
- if (port <= 0 || port > 65535)
- {
- throw new AlfrescoRuntimeException("Property 'port' is incorrect");
- }
- if (emailService == null)
- {
- throw new AlfrescoRuntimeException("Property 'emailService' not set");
- }
- if (blockedSenders == null)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Property 'blockedSenders' not set");
- }
- }
- if (allowedSenders == null)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Property 'allowedSenders' not set");
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onBootstrap(ApplicationEvent event)
- {
- check();
- }
-
- /**
- * {@inheritDoc}
- *
- * NO-OP
- */
- @Override
- protected void onShutdown(ApplicationEvent event)
- {
- }
-}
diff --git a/source/java/org/alfresco/email/server/EmailServiceImpl.java b/source/java/org/alfresco/email/server/EmailServiceImpl.java
index eef0ddad93..bb89e9b324 100644
--- a/source/java/org/alfresco/email/server/EmailServiceImpl.java
+++ b/source/java/org/alfresco/email/server/EmailServiceImpl.java
@@ -28,10 +28,12 @@ import java.util.Collection;
import java.util.Map;
import org.alfresco.email.server.handler.EmailMessageHandler;
-import org.alfresco.i18n.I18NUtil;
+import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
+import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.email.EmailMessage;
@@ -43,28 +45,47 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.ParameterCheck;
/**
* Concrete email service implementation. This is responsible for routing the
* emails into the server.
+ *
* @since 2.2
*/
public class EmailServiceImpl implements EmailService
{
- private static final Log log = LogFactory.getLog(EmailServiceImpl.class);
-
+ private static final String ERR_INBOUND_EMAIL_DISABLED = "email.server.err.inbound_mail_disabled";
+ private static final String ERR_INVALID_SUBJECT = "email.server.err.invalid_subject";
+ private static final String ERR_ACCESS_DENIED = "email.server.err.access_denied";
+ private static final String ERR_UNKNOWN_SOURCE_ADDRESS = "email.server.err.unknown_source_address";
+ private static final String ERR_USER_NOT_EMAIL_CONTRIBUTOR = "email.server.err.user_not_email_contributor";
+ private static final String ERR_NO_EMAIL_CONTRIBUTOR_GROUP = "email.server.err.no_email_contributor_group";
+ private static final String ERR_INVALID_NODE_ADDRESS = "email.server.err.invalid_node_address";
+ private static final String ERR_HANDLER_NOT_FOUND = "email.server.err.handler_not_found";
+
+ private NamespaceService namespaceService;
private NodeService nodeService;
private SearchService searchService;
private RetryingTransactionHelper retryingTransactionHelper;
- private boolean mailInboundEnabled;
+ private boolean emailInboundEnabled;
/** Login of user that is set as unknown. */
private String unknownUser;
/** List of message handlers */
private Map emailMessageHandlerMap;
+ /**
+ *
+ * @param namespaceService the service to resolve namespace prefixes
+ */
+ public void setNamespaceService(NamespaceService namespaceService)
+ {
+ this.namespaceService = namespaceService;
+ }
+
/**
* @param nodeService Alfresco Node Service
*/
@@ -113,9 +134,9 @@ public class EmailServiceImpl implements EmailService
this.unknownUser = unknownUser;
}
- public void setMailInboundEnabled(boolean mailInboundEnabled)
+ public void setEmailInboundEnabled(boolean mailInboundEnabled)
{
- this.mailInboundEnabled = mailInboundEnabled;
+ this.emailInboundEnabled = mailInboundEnabled;
}
/**
@@ -143,87 +164,114 @@ public class EmailServiceImpl implements EmailService
*/
private void processMessage(final NodeRef nodeRef, final EmailMessage message)
{
- if (!mailInboundEnabled)
+ if (!emailInboundEnabled)
{
- throw new EmailMessageException(I18NUtil.getMessage("email.server.mail-inbound-disabled"));
+ throw new EmailMessageException(ERR_INBOUND_EMAIL_DISABLED);
}
try
{
- RetryingTransactionCallback