mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Feature/acs 3015 analyse error prone action executor action (#1153)
* ACS-3015 move ErrorProneAction code to test folder * ACS-3015 remove old commented out code * ACS-3015 fix context * ACS-3015 fix context path * ACS-3015 move test context to test resources * ACS-3015 correct path to moved test context * ACS-3015 fix context problem for TestCase tests * ACS-3015 moved MockUserNotifier to test folder
This commit is contained in:
@@ -530,13 +530,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="errorProneActionExecutor" class="org.alfresco.repo.activities.feed.ErrorProneActionExecutor" parent="action-executer">
|
|
||||||
<property name="publicAction">
|
|
||||||
<value>false</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Import MailService from the OutboundSMTP subsystem (needed for email space/invited users actions) -->
|
<!-- Import MailService from the OutboundSMTP subsystem (needed for email space/invited users actions) -->
|
||||||
<bean id="mailService" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
<bean id="mailService" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
||||||
<property name="sourceApplicationContextFactory">
|
<property name="sourceApplicationContextFactory">
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -23,100 +23,100 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.activities.feed;
|
package org.alfresco.repo.activities.feed;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||||
import org.alfresco.repo.action.executer.TestModeable;
|
import org.alfresco.repo.action.executer.TestModeable;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
public class ErrorProneActionExecutor extends ActionExecuterAbstractBase
|
public class ErrorProneActionExecutor extends ActionExecuterAbstractBase
|
||||||
implements InitializingBean, TestModeable
|
implements InitializingBean, TestModeable
|
||||||
{
|
{
|
||||||
private static Log logger = LogFactory.getLog(ErrorProneActionExecutor.class);
|
private static Log logger = LogFactory.getLog(ErrorProneActionExecutor.class);
|
||||||
|
|
||||||
public static final String PARAM_FAILING_PERSON_NODEREF = "failingPersonNodeRef";
|
public static final String PARAM_FAILING_PERSON_NODEREF = "failingPersonNodeRef";
|
||||||
public static final String PARAM_PERSON_NODEREF = "personNodeRef";
|
public static final String PARAM_PERSON_NODEREF = "personNodeRef";
|
||||||
public static final String PARAM_USERNAME = "userName";
|
public static final String PARAM_USERNAME = "userName";
|
||||||
|
|
||||||
public static final String NAME = "errorProneActionExecutor";
|
public static final String NAME = "errorProneActionExecutor";
|
||||||
|
|
||||||
// count of number of successful notifications
|
// count of number of successful notifications
|
||||||
private AtomicInteger numSuccessful = new AtomicInteger();
|
private AtomicInteger numSuccessful = new AtomicInteger();
|
||||||
|
|
||||||
// count of number of failed notifications
|
// count of number of failed notifications
|
||||||
private AtomicInteger numFailed = new AtomicInteger();
|
private AtomicInteger numFailed = new AtomicInteger();
|
||||||
|
|
||||||
public int getNumSuccess()
|
public int getNumSuccess()
|
||||||
{
|
{
|
||||||
return numSuccessful.get();
|
return numSuccessful.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumFailed()
|
public int getNumFailed()
|
||||||
{
|
{
|
||||||
return numFailed.get();
|
return numFailed.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an email message
|
* Send an email message
|
||||||
*
|
*
|
||||||
* @throws AlfrescoRuntimeException
|
* @throws AlfrescoRuntimeException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void executeImpl(
|
protected void executeImpl(
|
||||||
final Action ruleAction,
|
final Action ruleAction,
|
||||||
final NodeRef actionedUponNodeRef)
|
final NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
NodeRef failingPersonNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_FAILING_PERSON_NODEREF);
|
NodeRef failingPersonNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_FAILING_PERSON_NODEREF);
|
||||||
NodeRef personNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_PERSON_NODEREF);
|
NodeRef personNodeRef = (NodeRef)ruleAction.getParameterValue(PARAM_PERSON_NODEREF);
|
||||||
String userName = (String)ruleAction.getParameterValue(PARAM_USERNAME);
|
String userName = (String)ruleAction.getParameterValue(PARAM_USERNAME);
|
||||||
|
|
||||||
System.out.println("userName = " + userName);
|
System.out.println("userName = " + userName);
|
||||||
|
|
||||||
if(personNodeRef.equals(failingPersonNodeRef))
|
if(personNodeRef.equals(failingPersonNodeRef))
|
||||||
{
|
{
|
||||||
numFailed.incrementAndGet();
|
numFailed.incrementAndGet();
|
||||||
throw new AlfrescoRuntimeException("");
|
throw new AlfrescoRuntimeException("");
|
||||||
}
|
}
|
||||||
|
|
||||||
numSuccessful.incrementAndGet();
|
numSuccessful.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the parameter definitions
|
* Add the parameter definitions
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||||
{
|
{
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_FAILING_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Failing Person NodeRef"));
|
paramList.add(new ParameterDefinitionImpl(PARAM_FAILING_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Failing Person NodeRef"));
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Person NodeRef"));
|
paramList.add(new ParameterDefinitionImpl(PARAM_PERSON_NODEREF, DataTypeDefinition.NODE_REF, true, "Person NodeRef"));
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_USERNAME, DataTypeDefinition.TEXT, true, "Username"));
|
paramList.add(new ParameterDefinitionImpl(PARAM_USERNAME, DataTypeDefinition.TEXT, true, "Username"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTestMode()
|
public boolean isTestMode()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTestMode(boolean testMode)
|
public void setTestMode(boolean testMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception
|
public void afterPropertiesSet() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -23,96 +23,72 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.activities.feed;
|
package org.alfresco.repo.activities.feed;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ActionService;
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
public class ErrorProneUserNotifier extends AbstractUserNotifier
|
public class ErrorProneUserNotifier extends AbstractUserNotifier
|
||||||
{
|
{
|
||||||
// private AtomicInteger numSuccessful = new AtomicInteger();
|
|
||||||
// private AtomicInteger numFailed = new AtomicInteger();
|
private NodeRef failingPersonNodeRef;
|
||||||
|
private ActionService actionService;
|
||||||
private NodeRef failingPersonNodeRef;
|
|
||||||
private ActionService actionService;
|
public ErrorProneUserNotifier(NodeRef failingPersonNodeRef)
|
||||||
|
{
|
||||||
public ErrorProneUserNotifier(NodeRef failingPersonNodeRef)
|
this.failingPersonNodeRef = failingPersonNodeRef;
|
||||||
{
|
}
|
||||||
this.failingPersonNodeRef = failingPersonNodeRef;
|
|
||||||
}
|
public void setActionService(ActionService actionService)
|
||||||
|
{
|
||||||
public void setActionService(ActionService actionService)
|
this.actionService = actionService;
|
||||||
{
|
}
|
||||||
this.actionService = actionService;
|
|
||||||
}
|
@Override
|
||||||
|
protected boolean skipUser(NodeRef personNodeRef)
|
||||||
@Override
|
{
|
||||||
protected boolean skipUser(NodeRef personNodeRef)
|
return false;
|
||||||
{
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
|
protected Long getFeedId(NodeRef personNodeRef)
|
||||||
@Override
|
{
|
||||||
protected Long getFeedId(NodeRef personNodeRef)
|
Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef);
|
||||||
{
|
|
||||||
Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef);
|
// where did we get up to ?
|
||||||
|
Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID);
|
||||||
// where did we get up to ?
|
if (emailFeedDBID != null)
|
||||||
Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID);
|
{
|
||||||
if (emailFeedDBID != null)
|
// increment min feed id
|
||||||
{
|
emailFeedDBID++;
|
||||||
// increment min feed id
|
}
|
||||||
emailFeedDBID++;
|
else
|
||||||
}
|
{
|
||||||
else
|
emailFeedDBID = -1L;
|
||||||
{
|
}
|
||||||
emailFeedDBID = -1L;
|
|
||||||
}
|
return emailFeedDBID;
|
||||||
|
}
|
||||||
return emailFeedDBID;
|
|
||||||
}
|
@Override
|
||||||
|
protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams,
|
||||||
// public int getNumSuccess()
|
Map<String, Object> model, String templateNodeRef)
|
||||||
// {
|
{
|
||||||
// return numSuccessful.get();
|
|
||||||
// }
|
String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
|
||||||
//
|
|
||||||
// public int getNumFailed()
|
Action action = actionService.createAction(ErrorProneActionExecutor.NAME);
|
||||||
// {
|
|
||||||
// return numFailed.get();
|
action.setParameterValue(ErrorProneActionExecutor.PARAM_FAILING_PERSON_NODEREF, failingPersonNodeRef);
|
||||||
// }
|
action.setParameterValue(ErrorProneActionExecutor.PARAM_PERSON_NODEREF, personNodeRef);
|
||||||
|
action.setParameterValue(ErrorProneActionExecutor.PARAM_USERNAME, userName);
|
||||||
@Override
|
|
||||||
protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams,
|
actionService.executeAction(action, null);
|
||||||
Map<String, Object> model, String templateNodeRef)
|
}
|
||||||
{
|
}
|
||||||
// super.notifyUser(personNodeRef, subjectText, model, templateNodeRef);
|
|
||||||
|
|
||||||
String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
|
|
||||||
|
|
||||||
Action action = actionService.createAction(ErrorProneActionExecutor.NAME);
|
|
||||||
|
|
||||||
action.setParameterValue(ErrorProneActionExecutor.PARAM_FAILING_PERSON_NODEREF, failingPersonNodeRef);
|
|
||||||
action.setParameterValue(ErrorProneActionExecutor.PARAM_PERSON_NODEREF, personNodeRef);
|
|
||||||
action.setParameterValue(ErrorProneActionExecutor.PARAM_USERNAME, userName);
|
|
||||||
|
|
||||||
actionService.executeAction(action, null);
|
|
||||||
// String userName = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
|
|
||||||
//
|
|
||||||
// System.out.println("userName = " + userName);
|
|
||||||
//
|
|
||||||
// if(personNodeRef.equals(failingPersonNodeRef))
|
|
||||||
// {
|
|
||||||
// numFailed.incrementAndGet();
|
|
||||||
// throw new AlfrescoRuntimeException("");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// numSuccessful.incrementAndGet();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -25,10 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.activities.feed;
|
package org.alfresco.repo.activities.feed;
|
||||||
|
|
||||||
import static junit.framework.Assert.fail;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
||||||
import org.alfresco.repo.domain.activities.ActivitiesDAO;
|
import org.alfresco.repo.domain.activities.ActivitiesDAO;
|
||||||
@@ -52,6 +48,7 @@ import org.alfresco.service.namespace.NamespaceService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -62,6 +59,7 @@ import org.quartz.JobDetail;
|
|||||||
import org.quartz.Scheduler;
|
import org.quartz.Scheduler;
|
||||||
import org.springframework.beans.factory.ObjectFactory;
|
import org.springframework.beans.factory.ObjectFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -71,10 +69,10 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author steveglover
|
* @author steveglover
|
||||||
*/
|
*/
|
||||||
public class FeedNotifierTest
|
@ContextConfiguration({"classpath:alfresco/application-context.xml",
|
||||||
|
"classpath:alfresco/feednotifier-tests/test-action-services-context.xml"})
|
||||||
|
public class FeedNotifierTest extends BaseSpringTest
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = null;
|
|
||||||
|
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
@@ -104,14 +102,12 @@ public class FeedNotifierTest
|
|||||||
{
|
{
|
||||||
ApplicationContextHelper.setUseLazyLoading(false);
|
ApplicationContextHelper.setUseLazyLoading(false);
|
||||||
ApplicationContextHelper.setNoAutoStart(true);
|
ApplicationContextHelper.setNoAutoStart(true);
|
||||||
|
|
||||||
ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception
|
public void before() throws Exception
|
||||||
{
|
{
|
||||||
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) ctx.getBean("ActivitiesFeed");
|
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) applicationContext.getBean("ActivitiesFeed");
|
||||||
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
|
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
|
||||||
this.feedNotifier = (FeedNotifierImpl) activitiesFeedCtx.getBean("feedNotifier");
|
this.feedNotifier = (FeedNotifierImpl) activitiesFeedCtx.getBean("feedNotifier");
|
||||||
this.activityService = (ActivityService) activitiesFeedCtx.getBean("activityService");
|
this.activityService = (ActivityService) activitiesFeedCtx.getBean("activityService");
|
||||||
@@ -119,7 +115,7 @@ public class FeedNotifierTest
|
|||||||
this.feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator");
|
this.feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator");
|
||||||
ObjectFactory<ActivitiesFeedModelBuilder> feedModelBuilderFactory = (ObjectFactory<ActivitiesFeedModelBuilder>) activitiesFeedCtx.getBean("feedModelBuilderFactory");
|
ObjectFactory<ActivitiesFeedModelBuilder> feedModelBuilderFactory = (ObjectFactory<ActivitiesFeedModelBuilder>) activitiesFeedCtx.getBean("feedModelBuilderFactory");
|
||||||
|
|
||||||
Scheduler scheduler = (Scheduler) ctx.getBean("schedulerFactory");
|
Scheduler scheduler = (Scheduler) applicationContext.getBean("schedulerFactory");
|
||||||
|
|
||||||
JobDetail feedGeneratorJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedGeneratorJobDetail");
|
JobDetail feedGeneratorJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedGeneratorJobDetail");
|
||||||
JobDetail postLookupJobDetail = (JobDetail) activitiesFeedCtx.getBean("postLookupJobDetail");
|
JobDetail postLookupJobDetail = (JobDetail) activitiesFeedCtx.getBean("postLookupJobDetail");
|
||||||
@@ -134,17 +130,17 @@ public class FeedNotifierTest
|
|||||||
scheduler.pauseJob(postCleanerJobDetail.getKey());
|
scheduler.pauseJob(postCleanerJobDetail.getKey());
|
||||||
scheduler.pauseJob(feedNotifierJobDetail.getKey());
|
scheduler.pauseJob(feedNotifierJobDetail.getKey());
|
||||||
|
|
||||||
this.personService = (PersonService) ctx.getBean("personService");
|
this.personService = (PersonService) applicationContext.getBean("personService");
|
||||||
this.nodeService = (NodeService) ctx.getBean("nodeService");
|
this.nodeService = (NodeService) applicationContext.getBean("nodeService");
|
||||||
this.namespaceService = (NamespaceService) ctx.getBean("namespaceService");
|
this.namespaceService = (NamespaceService) applicationContext.getBean("namespaceService");
|
||||||
this.siteService = (SiteService) ctx.getBean("siteService");
|
this.siteService = (SiteService) applicationContext.getBean("siteService");
|
||||||
this.repoAdminService = (RepoAdminService) ctx.getBean("repoAdminService");
|
this.repoAdminService = (RepoAdminService) applicationContext.getBean("repoAdminService");
|
||||||
this.transactionService = (TransactionService) ctx.getBean("transactionService");
|
this.transactionService = (TransactionService) applicationContext.getBean("transactionService");
|
||||||
this.postDAO = (ActivityPostDAO) ctx.getBean("postDAO");
|
this.postDAO = (ActivityPostDAO) applicationContext.getBean("postDAO");
|
||||||
this.fileFolderService = (FileFolderService) ctx.getBean("fileFolderService");
|
this.fileFolderService = (FileFolderService) applicationContext.getBean("fileFolderService");
|
||||||
this.subscriptionService = (SubscriptionService) ctx.getBean("SubscriptionService");
|
this.subscriptionService = (SubscriptionService) applicationContext.getBean("SubscriptionService");
|
||||||
this.errorProneActionExecutor = (ErrorProneActionExecutor) ctx.getBean("errorProneActionExecutor");
|
this.errorProneActionExecutor = (ErrorProneActionExecutor) applicationContext.getBean("errorProneActionExecutor");
|
||||||
this.actionService = (ActionService) ctx.getBean("ActionService");
|
this.actionService = (ActionService) applicationContext.getBean("ActionService");
|
||||||
|
|
||||||
// create some users
|
// create some users
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -23,95 +23,95 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.activities.feed;
|
package org.alfresco.repo.activities.feed;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A test user notifier.
|
* A test user notifier.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class MockUserNotifier extends AbstractUserNotifier
|
public class MockUserNotifier extends AbstractUserNotifier
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Default alfresco installation url
|
* Default alfresco installation url
|
||||||
*/
|
*/
|
||||||
private BitSet notifiedPersonsTracker = new BitSet();
|
private BitSet notifiedPersonsTracker = new BitSet();
|
||||||
private AtomicInteger count = new AtomicInteger(0);
|
private AtomicInteger count = new AtomicInteger(0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean skipUser(NodeRef personNodeRef)
|
protected boolean skipUser(NodeRef personNodeRef)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Long getFeedId(NodeRef personNodeRef)
|
protected Long getFeedId(NodeRef personNodeRef)
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef);
|
Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef);
|
||||||
|
|
||||||
// where did we get up to ?
|
// where did we get up to ?
|
||||||
Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID);
|
Long emailFeedDBID = (Long)personProps.get(ContentModel.PROP_EMAIL_FEED_ID);
|
||||||
if (emailFeedDBID != null)
|
if (emailFeedDBID != null)
|
||||||
{
|
{
|
||||||
// increment min feed id
|
// increment min feed id
|
||||||
emailFeedDBID++;
|
emailFeedDBID++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emailFeedDBID = -1L;
|
emailFeedDBID = -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
return emailFeedDBID;
|
return emailFeedDBID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams, Map<String, Object> model, String templateNodeRef)
|
protected void notifyUser(NodeRef personNodeRef, String subjectText, Object[] subjectParams, Map<String, Object> model, String templateNodeRef)
|
||||||
{
|
{
|
||||||
String username = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
|
String username = (String)nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
|
||||||
if(username.startsWith("user"))
|
if(username.startsWith("user"))
|
||||||
{
|
{
|
||||||
int id = Integer.parseInt(username.substring(4));
|
int id = Integer.parseInt(username.substring(4));
|
||||||
|
|
||||||
boolean b = false;
|
boolean b = false;
|
||||||
synchronized(notifiedPersonsTracker)
|
synchronized(notifiedPersonsTracker)
|
||||||
{
|
{
|
||||||
b = notifiedPersonsTracker.get(id);
|
b = notifiedPersonsTracker.get(id);
|
||||||
}
|
}
|
||||||
if(b)
|
if(b)
|
||||||
{
|
{
|
||||||
System.out.println("Already set: " + id);
|
System.out.println("Already set: " + id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
synchronized(notifiedPersonsTracker)
|
synchronized(notifiedPersonsTracker)
|
||||||
{
|
{
|
||||||
notifiedPersonsTracker.set(id);
|
notifiedPersonsTracker.set(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countNotifications()
|
public int countNotifications()
|
||||||
{
|
{
|
||||||
return count.get();
|
return count.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextUserId()
|
public int nextUserId()
|
||||||
{
|
{
|
||||||
synchronized(notifiedPersonsTracker)
|
synchronized(notifiedPersonsTracker)
|
||||||
{
|
{
|
||||||
return notifiedPersonsTracker.nextClearBit(1);
|
return notifiedPersonsTracker.nextClearBit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||||
|
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<bean id="errorProneActionExecutor" class="org.alfresco.repo.activities.feed.ErrorProneActionExecutor" parent="action-executer">
|
||||||
|
<property name="publicAction">
|
||||||
|
<value>false</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
Reference in New Issue
Block a user