Recent activities emails not being sent in Alfresco 4.2.c

After upgrading to Alfresco 4.2.c some users complained that they were not receiving the  Recent Activities emails as well as the Recent activities site’s widget was always empty.

After hours of digging around and tracing the source code down I realised that it had something to do with the user accounts. Alfresco synchronizes with the ActiveDirectory server to retreive all the system users and groups and they are created on Alfresco exactly as they are defined on AD, i.e., it is case sensitive.

ACCOUNTIn other words, we have different Alfresco users, some uppercase others lowercase. Despite this does not represent any issue when logging in to Alfresco Share, it turns out that it makes a huge difference when it comes to the Feed Generator subsystem.

The problem lies in the org.alfresco.repo.activities.feed.FeedTaskProcessor class which looks for new site’s activities (add/update/delete documents for instance) and determines who is candidate for notifications among all the users in the system. These notifications are eventually generated and inserted in to the alf_activity_feed database table:

activity tableSomewhere near line 328 (depending on the source file revision number) you can see how some users are excluded just by calling the canRead method.  This method returned false for all the Alfresco users that were defined uppercase on the ActiveDirectory database.

 // node read permission check (if nodeRef is present)
if (! canRead(ctx, recipient, model))
{
    excludedConnections++;
    continue;
}

So I hacked this bit ot code to include both checks, lower and uppercase:

 // node read permission check (if nodeRef is present)
if (! canRead(ctx, recipient, model))
{
  // Luis Rodríguez 22/01/2014 - Try also with uppercased name
  if (! canRead(ctx, recipient.toUpperCase(), model))
  {
    logger.debug("canRead no:" + recipient.toUpperCase());
    excludedConnections++;
    continue;
  }
}

That worked for me having to recompile Alfresco distribution and replace the alfresco-repository-4.2.c.jar file located in $ALFRESCO_HOME/tomcat/webapps/alfresco/WEB-INF/lib/.

Since I’m running a nightly build of Alfresco server (that means that I don’t know what Public SVN revision number is) and on the other hand, I checked out the source code from Alfresco SVN server using the COMMUNITY TAG 4.2c, these versions don’t match and replacing the JAR file threw lots of exception at Alfresco boot. Solution, extract the content of the original JAR file, overwrite the FeedTaskProcessor.class and pack the JAR file back again.

Following is the FeedTaskProcessor.class attached, hope it is helpful for someone.

https://dl.dropboxusercontent.com/u/11994518/injustfiveminutes/FeedTaskProcessor.class

Advertisements

One thought on “Recent activities emails not being sent in Alfresco 4.2.c

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s