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:
Glen Johnson
2008-07-10 10:10:03 +00:00
parent f0b7fc0569
commit f8d631f9f1
3 changed files with 45 additions and 13 deletions

View File

@@ -53,7 +53,6 @@ import org.alfresco.web.scripts.WebScriptRequest;
*/
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_CANCEL = "cancel";
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_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
private WorkflowService workflowService;
private PersonService personService;
@@ -84,6 +77,14 @@ public class Invite extends DeclarativeWebScript
private UserNameGenerator usernameGenerator;
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
*

View File

@@ -25,12 +25,14 @@
package org.alfresco.repo.web.scripts.invite;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.site.SiteModel;
import org.alfresco.repo.site.SiteService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.workflow.WorkflowPath;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.web.scripts.DeclarativeWebScript;
import org.alfresco.web.scripts.Status;
@@ -193,7 +195,23 @@ public class InviteResponse extends DeclarativeWebScript
private void acceptInvite(Map<String, Object> model, String workflowId,
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
// site invitation
@@ -225,7 +243,23 @@ public class InviteResponse extends DeclarativeWebScript
private void rejectInvite(Map<String, Object> model, String workflowId,
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
this.personService.deletePerson(inviteeUserName);

View File

@@ -71,9 +71,6 @@ public class Invites extends DeclarativeWebScript
// model key names
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
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
// are returned by query
wfTaskQuery.setProcessName(WF_INVITE_PROCESS_DEFINITION_QNAME);
wfTaskQuery.setProcessName(QName.createQName(Invite.WORKFLOW_DEFINITION_NAME));
// query for invite workflow tasks
List<WorkflowTask> wf_invite_tasks = this.workflowService.queryTasks(wfTaskQuery);