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