Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

124236 amorarasu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2) (PARTIAL MERGE)
      124190 amorarasu: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4)
         124132 arebegea: MNT-15573 : Site finder slow for a user who's member of many sites
            - added a new method to InvitationService to make use of the limit in the searchInvitation
            - sent and used the 200 limit from the site-finder.get.js in the script/ScriptInvitationService.java and passed the new parameter
            - for searchModeratedInvitations and searchNominatedInvitations methods of InvitationServiceImpl.java I added the use of the limit parameter
            - added some comments on ActivitiWorkflowEngine.java and TaskComponent.java to inform developers about the performance issues and possible improvement
            - added junit tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@124277 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-21 11:05:59 +00:00
parent d20141eb13
commit 741769a993
6 changed files with 162 additions and 26 deletions

View File

@@ -828,16 +828,22 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
}
/**
* This is the general search invitation method returning {@link Invitation}s
* {@inheritDoc}
*
* @param criteria InvitationSearchCriteria
* @return the list of start tasks for invitations
* @deprecated
*/
public List<Invitation> searchInvitation(final InvitationSearchCriteria criteria)
{
int limit = 200;
return searchInvitation(criteria, 200);
}
/**
* {@inheritDoc}
*/
public List<Invitation> searchInvitation(InvitationSearchCriteria criteria, int limit)
{
List<String> invitationIds = searchInvitationsForIds(criteria, limit);
return invitationIds.isEmpty() ? Collections.<Invitation>emptyList() : searchInvitation(criteria, invitationIds);
return invitationIds.isEmpty() ? Collections.<Invitation> emptyList() : searchInvitation(criteria, invitationIds);
}
private List<Invitation> searchInvitation(final InvitationSearchCriteria criteria, List<String> invitationIds)
@@ -872,7 +878,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
if (toSearch == InvitationSearchCriteria.InvitationType.ALL
|| toSearch == InvitationSearchCriteria.InvitationType.NOMINATED)
{
for (WorkflowTask task : searchNominatedInvitations(criteria))
for (WorkflowTask task : searchNominatedInvitations(criteria, limit))
{
String invitationId = task.getPath().getInstance().getId();
invitationIds.add(invitationId);
@@ -886,7 +892,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
(toSearch == InvitationSearchCriteria.InvitationType.ALL
|| toSearch == InvitationSearchCriteria.InvitationType.MODERATED))
{
for (WorkflowTask task: searchModeratedInvitations(criteria))
for (WorkflowTask task: searchModeratedInvitations(criteria, limit))
{
String invitationId = task.getPath().getInstance().getId();
invitationIds.add(invitationId);
@@ -937,14 +943,23 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
}
return true;
}
private List<WorkflowTask> searchModeratedInvitations(InvitationSearchCriteria criteria)
/**
*
* @param criteria criteria to search by
* @param limit maximum number of IDs to return. If less than 1, there is no limit.
* @return list of WorkflowTask representing moderated invitations
*/
private List<WorkflowTask> searchModeratedInvitations(InvitationSearchCriteria criteria, int limit)
{
long start = (logger.isDebugEnabled()) ? System.currentTimeMillis() : 0;
WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
if (limit > 0)
{
query.setLimit(limit);
}
Map<QName, Object> properties = new HashMap<QName, Object>();
String invitee = criteria.getInvitee();
if (invitee != null)
@@ -998,13 +1013,22 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
return results;
}
private List<WorkflowTask> searchNominatedInvitations(InvitationSearchCriteria criteria)
/**
*
* @param criteria
* @param limit maximum number of IDs to return. If less than 1, there is no limit.
* @return list of WorkflowTask representing nominated invitations
*/
private List<WorkflowTask> searchNominatedInvitations(InvitationSearchCriteria criteria, int limit)
{
long start = (logger.isDebugEnabled()) ? System.currentTimeMillis() : 0;
WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
if (limit > 0)
{
query.setLimit(limit);
}
String invitee = criteria.getInvitee();
if(invitee != null)
{