mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged V3.4-BUG-FIX to HEAD
30744: ALF-9524: WCM: Defining a complex type with 'abstract' attribute to true does not allow other complex types to define elements with the same name - Fix by Pavel 30804: ALF-9524: Fix to NPE by Pavel 30812: ALF-718: Rules Fire Emails before Transaction Commit/Rollback Added tests and moved email sending into a post commit callback. 30820: Fix for ALF-10516 - 'My Sites' dashlet should indicate it is loading rather than say 'No sites' 30824: Fixed ALF-10470: DeclaritiveRegistry is looping continuously and re-initializing - Only replicate removals for the cache. The reset always does a remove first. <cache name="org.alfresco.cache.webScriptsRegistryCache" ... replicateUpdates = false, ... </cache> 30827: ALF-10513 60k Site Performance: Unable to delete user + request not acknowledged for 2 minutes Now about 3 to 4 seconds 30828: Andy H recommended change to lucene indexer values 30831: ALF-718: Fix for InvitationServiceImplTest Fixes behaviour broken by original fix for ALF-718: the send-after-commit does NOT work for the invitation service, so it was necessary to change the code to only send-after-commit in the context of a rule. 30843: Fixed ALF-7698 "Defects in tags picker in SHARE." according to feedback provided in ALF-9953 "Decide order where new items shall appear in the object finder." 30844: ALF-9544 - Inbound email restricts file name to 86 characters or less. used QName.createQNameWithValidLocalName() as suggested. added new EmailServiceImplTest 30849: Fixed ALF-8776 "Rule details dialog handling of apostrophes" 30862: Merged DEV/TEMPORARY to V3.4-BUG-FIX (with improvements) 30856: ALF-10288: Regression of ALF-1997: non domain users cannot bypass SSO in Share using /share/page?pt=login In SSOAuthenticationFilter.doFilter() method added check (PAGE_SERVLET_PATH.equals(req.getServletPath()) && LOGIN_PATH_INFORMATION.equals(req.getPathInfo()). 30864: SMTP Server, To and From address format. - Out standards for from and to address were stuck in the 1980s! 30867: ALF-10517 - 'My Content' slow - performance improvements by reworking Lucene queries used to retrieve recently modified and recently created content for a user - converted queries to fts-alfresco - improvements from 3.5sec per page render down to 1.1 secs 30874: MERGE DEV to V3.4-BUG-FIX 30851 : ALF-9558 - Unchecked Return Value 30882: - ScriptGroup.isRootGroup() now stops if it finds a single parent rather than doing a size on all parent groups. Not sure the logic (not changed by me) is correct as it includes parents that are site groups. - SiteServiceImpl now only gets the specified number of sites. Sometimes it would have return more if AuthorityDAOImpl switched approach used to get containing authorities. - Overloaded getContainingAuthorities to take a size parameter, deprecated other and switched calling code Done for isRootGroup activity. 30910: - Fix build error - Found a better way to use filter in AuthorityDAOImpl.getContainingAuthoritiesInZone so that we don't need to reset the filter, by using the +ve hits from first approach if we switch to second approach. 30925: - ALF-10501 60k Site Performance: Searching for a group to add to a site with a value that matches a few sites takes 2 minutes ALF-10502 60k Site Performance: Admin Console | Groups: search with a value that matches a few sites takes 70 seconds ALF-10504 60k Site Performance: Admin Console | Groups | Browse Groups page appears corrupt as it never finishes loading - All the above were slow as a result of ScriptGroup.isRootGroup() - ScriptGroup.isRootGroup() and ScriptGroup.isAdminGroup() removed - Checked with KevinR that these are not needed any more. - Removed code added on 30 Sep 11 to support isRootGroup (the size parameter to AuthorityDAO.getContainingAuthorities) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30935 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -42,6 +42,8 @@ import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
@@ -65,6 +67,14 @@ public class EmailServiceImpl implements EmailService
|
||||
private SearchService searchService;
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
private AuthorityService authorityService;
|
||||
|
||||
/**
|
||||
* The authority that needs to contain the users and groups
|
||||
* who are allowed to contribute email.
|
||||
*/
|
||||
private String emailContributorsAuthority="EMAIL_CONTRIBUTORS";
|
||||
|
||||
private static Log logger = LogFactory.getLog(EmailServiceImpl.class);
|
||||
|
||||
private boolean emailInboundEnabled;
|
||||
/** Login of user that is set as unknown. */
|
||||
@@ -337,10 +347,19 @@ public class EmailServiceImpl implements EmailService
|
||||
{
|
||||
if (unknownUser == null || unknownUser.length() == 0)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("unable to find user for from: " + from);
|
||||
}
|
||||
throw new EmailMessageException(ERR_UNKNOWN_SOURCE_ADDRESS, from);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("unable to find user for from - return anonymous: " + from);
|
||||
}
|
||||
|
||||
userName = unknownUser;
|
||||
}
|
||||
}
|
||||
@@ -375,13 +394,24 @@ public class EmailServiceImpl implements EmailService
|
||||
/**
|
||||
* Check that the user is the member in <b>EMAIL_CONTRIBUTORS</b> group
|
||||
*
|
||||
* @param userName User name
|
||||
* @param userName Alfresco user name
|
||||
* @return True if the user is member of the group
|
||||
* @exception EmailMessageException Exception will be thrown if the <b>EMAIL_CONTRIBUTORS</b> group isn't found
|
||||
*/
|
||||
private boolean isEmailContributeUser(String userName)
|
||||
{
|
||||
return this.authorityService.getAuthoritiesForUser(userName).contains(
|
||||
authorityService.getName(AuthorityType.GROUP, "EMAIL_CONTRIBUTORS"));
|
||||
authorityService.getName(AuthorityType.GROUP, getEmailContributorsAuthority()));
|
||||
}
|
||||
|
||||
public void setEmailContributorsAuthority(
|
||||
String emailContributorsAuthority)
|
||||
{
|
||||
this.emailContributorsAuthority = emailContributorsAuthority;
|
||||
}
|
||||
|
||||
public String getEmailContributorsAuthority()
|
||||
{
|
||||
return emailContributorsAuthority;
|
||||
}
|
||||
}
|
||||
|
@@ -18,52 +18,36 @@
|
||||
*/
|
||||
package org.alfresco.email.server;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.email.server.impl.subetha.SubethaEmailMessage;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.imap.ImapServiceImpl;
|
||||
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.person.PersonServiceImpl;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.admin.AdminService;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.email.EmailMessage;
|
||||
import org.alfresco.service.cmr.email.EmailMessageException;
|
||||
import org.alfresco.service.cmr.email.EmailService;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.tools.ant.filters.StringInputStream;
|
||||
@@ -71,8 +55,6 @@ import org.springframework.context.ApplicationContext;
|
||||
|
||||
import com.sun.mail.smtp.SMTPMessage;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Unit test of EmailServiceImplTest
|
||||
* @author mrogers
|
||||
@@ -205,7 +187,7 @@ public class EmailServiceImplTest extends TestCase
|
||||
InputStream is = new StringInputStream(bos.toString());
|
||||
assertNotNull("is is null", is);
|
||||
|
||||
SubethaEmailMessage m = new SubethaEmailMessage(from, to, is);
|
||||
SubethaEmailMessage m = new SubethaEmailMessage(is);
|
||||
|
||||
emailService.importMessage(m);
|
||||
fail("anonymous user not rejected");
|
||||
@@ -221,6 +203,9 @@ public class EmailServiceImplTest extends TestCase
|
||||
*
|
||||
* Send From the test user TEST_EMAIL to the test user's home
|
||||
*/
|
||||
{
|
||||
logger.debug("Step 2");
|
||||
|
||||
String from = TEST_EMAIL;
|
||||
String to = testUserHomeDBID;
|
||||
String content = "hello world";
|
||||
@@ -241,10 +226,85 @@ public class EmailServiceImplTest extends TestCase
|
||||
InputStream is = new StringInputStream(bos.toString());
|
||||
assertNotNull("is is null", is);
|
||||
|
||||
SubethaEmailMessage m = new SubethaEmailMessage(from, to, is);
|
||||
SubethaEmailMessage m = new SubethaEmailMessage(is);
|
||||
|
||||
emailService.importMessage(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 3
|
||||
*
|
||||
* From with < name@ domain > format
|
||||
*
|
||||
* Send From the test user <TEST_EMAIL> to the test user's home
|
||||
*/
|
||||
{
|
||||
logger.debug("Step 3");
|
||||
|
||||
String from = " \"Joe Bloggs\" <" + TEST_EMAIL + ">";
|
||||
String to = testUserHomeDBID;
|
||||
String content = "hello world";
|
||||
|
||||
Session sess = Session.getDefaultInstance(new Properties());
|
||||
assertNotNull("sess is null", sess);
|
||||
SMTPMessage msg = new SMTPMessage(sess);
|
||||
InternetAddress[] toa = { new InternetAddress(to) };
|
||||
|
||||
msg.setFrom(new InternetAddress(from));
|
||||
msg.setRecipients(Message.RecipientType.TO, toa);
|
||||
msg.setSubject("JavaMail APIs transport.java Test");
|
||||
msg.setContent(content, "text/plain");
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
msg.writeTo(System.out);
|
||||
msg.writeTo(bos);
|
||||
InputStream is = new StringInputStream(bos.toString());
|
||||
assertNotNull("is is null", is);
|
||||
|
||||
SubethaEmailMessage m = new SubethaEmailMessage(is);
|
||||
|
||||
emailService.importMessage(m);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Step 4
|
||||
// *
|
||||
// * From with <e=name@domain> format
|
||||
// *
|
||||
// * RFC3696
|
||||
// *
|
||||
// * Send From the test user <TEST_EMAIL> to the test user's home
|
||||
// */
|
||||
// {
|
||||
// logger.debug("Step 4 <local tag=name@ domain > format");
|
||||
//
|
||||
// String from = "\"Joe Bloggs\" <e=" + TEST_EMAIL + ">";
|
||||
// String to = testUserHomeDBID;
|
||||
// String content = "hello world";
|
||||
//
|
||||
// Session sess = Session.getDefaultInstance(new Properties());
|
||||
// assertNotNull("sess is null", sess);
|
||||
// SMTPMessage msg = new SMTPMessage(sess);
|
||||
// InternetAddress[] toa = { new InternetAddress(to) };
|
||||
//
|
||||
// msg.setFrom(new InternetAddress(from));
|
||||
// msg.setRecipients(Message.RecipientType.TO, toa);
|
||||
// msg.setSubject("JavaMail APIs transport.java Test");
|
||||
// msg.setContent(content, "text/plain");
|
||||
//
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
// msg.writeTo(System.out);
|
||||
// msg.writeTo(bos);
|
||||
// InputStream is = new StringInputStream(bos.toString());
|
||||
// assertNotNull("is is null", is);
|
||||
//
|
||||
// SubethaEmailMessage m = new SubethaEmailMessage(is);
|
||||
//
|
||||
// emailService.importMessage(m);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -313,7 +373,7 @@ public class EmailServiceImplTest extends TestCase
|
||||
InputStream is = new StringInputStream(bos.toString());
|
||||
assertNotNull("is is null", is);
|
||||
|
||||
SubethaEmailMessage m = new SubethaEmailMessage(from, to, is);
|
||||
SubethaEmailMessage m = new SubethaEmailMessage(is);
|
||||
|
||||
emailService.importMessage(m);
|
||||
|
||||
|
@@ -101,11 +101,8 @@ public class SubethaEmailMessage implements EmailMessage
|
||||
processMimeMessage(mimeMessage);
|
||||
}
|
||||
|
||||
public SubethaEmailMessage(String from, String to, InputStream dataInputStream)
|
||||
public SubethaEmailMessage(InputStream dataInputStream)
|
||||
{
|
||||
this.to = to;
|
||||
this.from = from;
|
||||
|
||||
MimeMessage mimeMessage = null;
|
||||
try
|
||||
{
|
||||
@@ -136,8 +133,16 @@ public class SubethaEmailMessage implements EmailMessage
|
||||
{
|
||||
throw new EmailMessageException(ERR_NO_FROM_ADDRESS);
|
||||
}
|
||||
if(addresses[0] instanceof InternetAddress)
|
||||
{
|
||||
from = ((InternetAddress)addresses[0]).getAddress();
|
||||
}
|
||||
else
|
||||
{
|
||||
from = addresses[0].toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (to == null)
|
||||
{
|
||||
@@ -154,6 +159,15 @@ public class SubethaEmailMessage implements EmailMessage
|
||||
{
|
||||
throw new EmailMessageException(ERR_NO_TO_ADDRESS);
|
||||
}
|
||||
if(addresses[0] instanceof InternetAddress)
|
||||
{
|
||||
to = ((InternetAddress)addresses[0]).getAddress();
|
||||
}
|
||||
else
|
||||
{
|
||||
to = addresses[0].toString();
|
||||
}
|
||||
|
||||
to = addresses[0].toString();
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,9 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
import org.alfresco.email.server.EmailServer;
|
||||
import org.alfresco.service.cmr.email.EmailMessage;
|
||||
import org.alfresco.service.cmr.email.EmailMessageException;
|
||||
@@ -41,7 +44,7 @@ import org.subethamail.smtp.server.SMTPServer;
|
||||
*/
|
||||
public class SubethaEmailServer extends EmailServer
|
||||
{
|
||||
private final static Log log = LogFactory.getLog(SubethaEmailServer.class);
|
||||
private final static Log logger = LogFactory.getLog(SubethaEmailServer.class);
|
||||
|
||||
private SMTPServer serverImpl;
|
||||
|
||||
@@ -91,7 +94,6 @@ public class SubethaEmailServer extends EmailServer
|
||||
|
||||
private List<String> EMPTY_LIST = new LinkedList<String>();
|
||||
|
||||
private String from;
|
||||
private MessageContext messageContext;
|
||||
List<Delivery> deliveries = new ArrayList<Delivery>();
|
||||
|
||||
@@ -105,11 +107,25 @@ public class SubethaEmailServer extends EmailServer
|
||||
return messageContext;
|
||||
}
|
||||
|
||||
public void from(String from) throws RejectException
|
||||
public void from(String fromString) throws RejectException
|
||||
{
|
||||
this.from = from;
|
||||
String from = fromString;
|
||||
|
||||
try
|
||||
{
|
||||
InternetAddress a = new InternetAddress(from);
|
||||
from = a.getAddress();
|
||||
}
|
||||
catch (AddressException e)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("check whether user is allowed to send email from" + from);
|
||||
}
|
||||
filterSender(from);
|
||||
}
|
||||
catch (EmailMessageException e)
|
||||
@@ -187,7 +203,7 @@ public class SubethaEmailServer extends EmailServer
|
||||
EmailMessage emailMessage;
|
||||
try
|
||||
{
|
||||
emailMessage = new SubethaEmailMessage(from, delivery.getRecipient(), data);
|
||||
emailMessage = new SubethaEmailMessage(data);
|
||||
getEmailService().importMessage(emailMessage);
|
||||
}
|
||||
catch (EmailMessageException e)
|
||||
|
Reference in New Issue
Block a user