mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Latest fixes for Java-backed Invite REST API Web Scripts - but invites.get (pending invites) still failing on Unit Tests
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9714 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -53,7 +53,6 @@ import org.alfresco.web.scripts.WebScriptRequest;
|
|||||||
*/
|
*/
|
||||||
public class Invite extends DeclarativeWebScript
|
public class Invite extends DeclarativeWebScript
|
||||||
{
|
{
|
||||||
private static final String WORKFLOW_DEFINITION_NAME = "jbpm$wf:invite";
|
|
||||||
private static final String ACTION_START = "start";
|
private static final String ACTION_START = "start";
|
||||||
private static final String ACTION_CANCEL = "cancel";
|
private static final String ACTION_CANCEL = "cancel";
|
||||||
private static final String TRANSITION_SEND_INVITE = "sendInvite";
|
private static final String TRANSITION_SEND_INVITE = "sendInvite";
|
||||||
@@ -68,12 +67,6 @@ public class Invite extends DeclarativeWebScript
|
|||||||
private static final String PARAM_SITE_SHORT_NAME = "siteShortName";
|
private static final String PARAM_SITE_SHORT_NAME = "siteShortName";
|
||||||
private static final String PARAM_WORKFLOW_ID = "workflowId";
|
private static final String PARAM_WORKFLOW_ID = "workflowId";
|
||||||
|
|
||||||
// workflow properties
|
|
||||||
public static final String WF_PROP_INVITER_USER_NAME = "wf:inviterUserName";
|
|
||||||
public static final String WF_PROP_INVITEE_USER_NAME = "wf:inviteeUserName";
|
|
||||||
public static final String WF_PROP_SITE_SHORT_NAME = "wf:siteShortName";
|
|
||||||
private static final String WF_PROP_INVITEE_GEN_PASSWORD = "wf:inviteeGenPassword";
|
|
||||||
|
|
||||||
// services
|
// services
|
||||||
private WorkflowService workflowService;
|
private WorkflowService workflowService;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
@@ -84,6 +77,14 @@ public class Invite extends DeclarativeWebScript
|
|||||||
private UserNameGenerator usernameGenerator;
|
private UserNameGenerator usernameGenerator;
|
||||||
private PasswordGenerator passwordGenerator;
|
private PasswordGenerator passwordGenerator;
|
||||||
|
|
||||||
|
// workflow properties
|
||||||
|
public static final String WF_PROP_INVITER_USER_NAME = "wf:inviterUserName";
|
||||||
|
public static final String WF_PROP_INVITEE_USER_NAME = "wf:inviteeUserName";
|
||||||
|
public static final String WF_PROP_SITE_SHORT_NAME = "wf:siteShortName";
|
||||||
|
private static final String WF_PROP_INVITEE_GEN_PASSWORD = "wf:inviteeGenPassword";
|
||||||
|
|
||||||
|
public static final String WORKFLOW_DEFINITION_NAME = "jbpm$wf:invite";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the workflowService property
|
* Sets the workflowService property
|
||||||
*
|
*
|
||||||
|
@@ -25,12 +25,14 @@
|
|||||||
package org.alfresco.repo.web.scripts.invite;
|
package org.alfresco.repo.web.scripts.invite;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.repo.site.SiteService;
|
import org.alfresco.repo.site.SiteService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowPath;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||||
import org.alfresco.web.scripts.DeclarativeWebScript;
|
import org.alfresco.web.scripts.DeclarativeWebScript;
|
||||||
import org.alfresco.web.scripts.Status;
|
import org.alfresco.web.scripts.Status;
|
||||||
@@ -193,7 +195,23 @@ public class InviteResponse extends DeclarativeWebScript
|
|||||||
private void acceptInvite(Map<String, Object> model, String workflowId,
|
private void acceptInvite(Map<String, Object> model, String workflowId,
|
||||||
String inviteeUserName, String siteShortName)
|
String inviteeUserName, String siteShortName)
|
||||||
{
|
{
|
||||||
this.workflowService.signal(workflowId, TRANSITION_ACCEPT);
|
// get workflow paths associated with given workflow ID
|
||||||
|
List<WorkflowPath> wfPaths = this.workflowService.getWorkflowPaths(workflowId);
|
||||||
|
|
||||||
|
// throw web script exception if there is not at least one workflow path
|
||||||
|
// associated with this workflow ID
|
||||||
|
if ((wfPaths == null) || (wfPaths.size() == 0))
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
|
||||||
|
"There are no workflow paths associated with workflow ID: "
|
||||||
|
+ workflowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get workflow path ID for path matching workflow ID
|
||||||
|
WorkflowPath wfPath = wfPaths.get(0);
|
||||||
|
String wfPathID = wfPath.id;
|
||||||
|
|
||||||
|
this.workflowService.signal(wfPathID, TRANSITION_ACCEPT);
|
||||||
|
|
||||||
// enable invitee person's user account because he/she has accepted the
|
// enable invitee person's user account because he/she has accepted the
|
||||||
// site invitation
|
// site invitation
|
||||||
@@ -225,7 +243,23 @@ public class InviteResponse extends DeclarativeWebScript
|
|||||||
private void rejectInvite(Map<String, Object> model, String workflowId,
|
private void rejectInvite(Map<String, Object> model, String workflowId,
|
||||||
String inviteeUserName, String siteShortName)
|
String inviteeUserName, String siteShortName)
|
||||||
{
|
{
|
||||||
this.workflowService.signal(workflowId, TRANSITION_REJECT);
|
// get workflow paths associated with given workflow ID
|
||||||
|
List<WorkflowPath> wfPaths = this.workflowService.getWorkflowPaths(workflowId);
|
||||||
|
|
||||||
|
// throw web script exception if there is not at least one workflow path
|
||||||
|
// associated with this workflow ID
|
||||||
|
if ((wfPaths == null) || (wfPaths.size() == 0))
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
|
||||||
|
"There are no workflow paths associated with workflow ID: "
|
||||||
|
+ workflowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get workflow path ID for path matching workflow ID
|
||||||
|
WorkflowPath wfPath = wfPaths.get(0);
|
||||||
|
String wfPathID = wfPath.id;
|
||||||
|
|
||||||
|
this.workflowService.signal(wfPathID, TRANSITION_REJECT);
|
||||||
|
|
||||||
// delete the person created for invitee
|
// delete the person created for invitee
|
||||||
this.personService.deletePerson(inviteeUserName);
|
this.personService.deletePerson(inviteeUserName);
|
||||||
|
@@ -71,9 +71,6 @@ public class Invites extends DeclarativeWebScript
|
|||||||
// model key names
|
// model key names
|
||||||
private static final String MODEL_KEY_NAME_INVITES = "invites";
|
private static final String MODEL_KEY_NAME_INVITES = "invites";
|
||||||
|
|
||||||
// invite process definition name
|
|
||||||
private static final QName WF_INVITE_PROCESS_DEFINITION_QNAME = QName.createQName("wf:invite");
|
|
||||||
|
|
||||||
// service instances
|
// service instances
|
||||||
private WorkflowService workflowService;
|
private WorkflowService workflowService;
|
||||||
|
|
||||||
@@ -183,7 +180,7 @@ public class Invites extends DeclarativeWebScript
|
|||||||
|
|
||||||
// set process name to "wf:invite" so that only tasks associated with invite workflow instances
|
// set process name to "wf:invite" so that only tasks associated with invite workflow instances
|
||||||
// are returned by query
|
// are returned by query
|
||||||
wfTaskQuery.setProcessName(WF_INVITE_PROCESS_DEFINITION_QNAME);
|
wfTaskQuery.setProcessName(QName.createQName(Invite.WORKFLOW_DEFINITION_NAME));
|
||||||
|
|
||||||
// query for invite workflow tasks
|
// query for invite workflow tasks
|
||||||
List<WorkflowTask> wf_invite_tasks = this.workflowService.queryTasks(wfTaskQuery);
|
List<WorkflowTask> wf_invite_tasks = this.workflowService.queryTasks(wfTaskQuery);
|
||||||
|
Reference in New Issue
Block a user