Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.0/Cloud)

85567: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      85475: MNT-12398 : FeedNotifier - Users mixed up, fail to send notification email
      Fixed formatting.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94504 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 09:31:48 +00:00
parent 9c0e08b45d
commit 33cb8d37d6

View File

@@ -104,33 +104,33 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
public void setNumThreads(int numThreads)
{
this.numThreads = numThreads;
this.numThreads = numThreads;
}
public void setBatchSize(int batchSize)
{
this.batchSize = batchSize;
this.batchSize = batchSize;
}
public void setUserNotifier(UserNotifier userNotifier)
public void setUserNotifier(UserNotifier userNotifier)
{
this.userNotifier = userNotifier;
}
this.userNotifier = userNotifier;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
this.fileFolderService = fileFolderService;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setPersonService(PersonService personService)
{
@@ -272,16 +272,16 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
try
{
if (! feedEmailTemplateLocation.getQueryLanguage().equals(SearchService.LANGUAGE_XPATH))
if (!feedEmailTemplateLocation.getQueryLanguage().equals(SearchService.LANGUAGE_XPATH))
{
logger.error("Cannot find the activities email template - repository location query language is not 'xpath': "+feedEmailTemplateLocation.getQueryLanguage());
logger.error("Cannot find the activities email template - repository location query language is not 'xpath': " + feedEmailTemplateLocation.getQueryLanguage());
return null;
}
List<NodeRef> nodeRefs = searchService.selectNodes(nodeService.getRootNode(store), xpath, null, namespaceService, false);
if (nodeRefs.size() != 1)
{
logger.error("Cannot find the activities email template: "+xpath);
logger.error("Cannot find the activities email template: " + xpath);
return null;
}
@@ -300,7 +300,7 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
}
else
{
logger.error("Unsupported location type: "+locationType);
logger.error("Unsupported location type: " + locationType);
return null;
}
}
@@ -335,28 +335,28 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
final String tenantDomain = TenantUtil.getCurrentDomain();
// process the feeds using the batch processor {@link BatchProcessor}
BatchProcessor.BatchProcessWorker<PersonInfo> worker = new BatchProcessor.BatchProcessWorker<PersonInfo>()
{
public String getIdentifier(final PersonInfo person)
{
StringBuilder sb = new StringBuilder("Person ");
sb.append(person.getUserName());
return sb.toString();
}
BatchProcessor.BatchProcessWorker<PersonInfo> worker = new BatchProcessor.BatchProcessWorker<PersonInfo>()
{
public String getIdentifier(final PersonInfo person)
{
StringBuilder sb = new StringBuilder("Person ");
sb.append(person.getUserName());
return sb.toString();
}
public void beforeProcess() throws Throwable
{
AuthenticationUtil.setFullyAuthenticatedUser(currentUser);
}
public void beforeProcess() throws Throwable
{
AuthenticationUtil.setFullyAuthenticatedUser(currentUser);
}
public void afterProcess() throws Throwable
{
AuthenticationUtil.clearCurrentSecurityContext();
}
public void afterProcess() throws Throwable
{
AuthenticationUtil.clearCurrentSecurityContext();
}
public void process(final PersonInfo person) throws Throwable
{
final RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();
public void process(final PersonInfo person) throws Throwable
{
final RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();
txHelper.setMaxRetries(0);
TenantUtil.runAsTenant(new TenantRunAsWork<Void>()
@@ -375,7 +375,7 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
return null;
}
}, tenantDomain);
}
}
private void processInternal(final PersonInfo person) throws Exception
{
@@ -388,38 +388,38 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
int entryCnt = result.getFirst();
final long maxFeedId = result.getSecond();
Long currentMaxFeedId = (Long)nodeService.getProperty(personNodeRef, ContentModel.PROP_EMAIL_FEED_ID);
if ((currentMaxFeedId == null) || (currentMaxFeedId < maxFeedId))
{
nodeService.setProperty(personNodeRef, ContentModel.PROP_EMAIL_FEED_ID, maxFeedId);
}
Long currentMaxFeedId = (Long) nodeService.getProperty(personNodeRef, ContentModel.PROP_EMAIL_FEED_ID);
if ((currentMaxFeedId == null) || (currentMaxFeedId < maxFeedId))
{
nodeService.setProperty(personNodeRef, ContentModel.PROP_EMAIL_FEED_ID, maxFeedId);
}
userCnt.incrementAndGet();
feedEntryCnt.addAndGet(entryCnt);
}
}
catch (InvalidNodeRefException inre)
{
// skip this person - eg. no longer exists ?
logger.warn("Skip feed notification for user ("+personNodeRef+"): " + inre.getMessage());
}
}
};
userCnt.incrementAndGet();
feedEntryCnt.addAndGet(entryCnt);
}
}
catch (InvalidNodeRefException inre)
{
// skip this person - eg. no longer exists ?
logger.warn("Skip feed notification for user (" + personNodeRef + "): " + inre.getMessage());
}
}
};
// grab people for the batch processor in chunks of size batchSize
BatchProcessWorkProvider<PersonInfo> provider = new BatchProcessWorkProvider<PersonInfo>()
{
private int skip = 0;
private int maxItems = batchSize;
// grab people for the batch processor in chunks of size batchSize
BatchProcessWorkProvider<PersonInfo> provider = new BatchProcessWorkProvider<PersonInfo>()
{
private int skip = 0;
private int maxItems = batchSize;
private boolean hasMore = true;
@Override
public int getTotalEstimatedWorkSize()
{
return personService.countPeople();
}
@Override
public int getTotalEstimatedWorkSize()
{
return personService.countPeople();
}
@Override
@Override
public Collection<PersonInfo> getNextWork()
{
if (!hasMore)
@@ -432,18 +432,18 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
hasMore = people.hasMoreItems();
return page;
}
};
};
final RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();
txHelper.setMaxRetries(0);
new BatchProcessor<PersonInfo>(
"FeedNotifier",
txHelper,
provider,
numThreads, batchSize,
applicationContext,
logger, 100).process(worker, true);
new BatchProcessor<PersonInfo>(
"FeedNotifier",
txHelper,
provider,
numThreads, batchSize,
applicationContext,
logger, 100).process(worker, true);
}
catch (Throwable e)
{
@@ -459,8 +459,8 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
}
finally
{
int count = userCnt.get();
int entryCount = feedEntryCnt.get();
int count = userCnt.get();
int entryCount = feedEntryCnt.get();
// assume sends are synchronous - hence bump up to last max feed id
if (count > 0)
@@ -485,9 +485,9 @@ public class FeedNotifierImpl implements FeedNotifier, ApplicationContextAware
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
this.applicationContext = applicationContext;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
this.applicationContext = applicationContext;
}
}