Various Invite Service fixes

- removed unnecessary siteService property from 'invites' web script
- removed unnecessary getSentDateFromInvite(...)) method from InviteHelper.java
- added comments to property getters in InviteInfo.java
- return sentInviteDate, inviteeSiteRole and invitationStatus from 'invites' Web Script   

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10493 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Glen Johnson
2008-08-22 12:39:24 +00:00
parent e0921fe3ef
commit d0d19ba6ea
4 changed files with 48 additions and 70 deletions

View File

@@ -24,7 +24,6 @@
*/
package org.alfresco.repo.web.scripts.invite;
import java.util.Date;
import java.util.List;
import org.alfresco.service.cmr.workflow.WorkflowService;
@@ -93,53 +92,4 @@ public class InviteHelper
return inviteeSiteRole;
}
}
/**
* Gets the date that the invite, with the given invite ID, was sent to the invitee
*
* @param inviteId the ID of the invitation
* from which to retrieve the sent date
* @return the date that the invite was sent to the invitee
* Returns <pre>null</pre> if no invitation
* found matching the given invite ID
*/
static Date getSentDateFromInvite(String inviteId, WorkflowService workflowService,
NamespaceService namespaceService)
{
// create workflow task query
WorkflowTaskQuery wfTaskQuery = new WorkflowTaskQuery();
wfTaskQuery.setProcessId(inviteId);
// set process name to "wf:invite" so that only tasks associated with
// invite workflow instances are returned by query
wfTaskQuery.setProcessName(QName.createQName("wf:invite", namespaceService));
// pick up the start task because it has the "wf:inviteeSiteRole" property set with the
// site role value that we want to retrieve
wfTaskQuery.setTaskState(WorkflowTaskState.COMPLETED);
wfTaskQuery.setTaskName(QName.createQName(Invite.WF_INVITE_TASK_INVITE_TO_SITE, namespaceService));
// query for invite workflow task associate
List<WorkflowTask> inviteStartTasks = workflowService
.queryTasks(wfTaskQuery);
// if no results were returned for given inviteID, then return
// site role as null
if (inviteStartTasks.size() == 0)
{
return null;
}
else
{
// there should be only one start task returned for the given invite ID
// so just take the first one in the list
WorkflowTask inviteStartTask = inviteStartTasks.get(0);
Date sentInviteDate = (Date) inviteStartTask.properties.get(
QName.createQName(Invite.WF_PROP_SENT_INVITE_DATE, namespaceService));
return sentInviteDate;
}
}
}

View File

@@ -102,25 +102,53 @@ public class InviteInfo
return inviteId;
}
public ScriptNode getInviteePerson() {
/**
* Gets the invitee person
*
* @return the invitee person
*/
public ScriptNode getInviteePerson()
{
return inviteePerson;
}
public ScriptNode getInviterPerson() {
/**
* Gets the inviter person
*
* @return the inviter person
*/
public ScriptNode getInviterPerson()
{
return inviterPerson;
}
public Date getSentInviteDate() {
/**
* Gets the sent invite date
*
* @return the sent invite date
*/
public Date getSentInviteDate()
{
return sentInviteDate;
}
public String getInvitationStatus() {
/**
* Gets the invitation status
*
* @return the invitation status
*/
public String getInvitationStatus()
{
return invitationStatus;
}
public String getRole() {
/**
* Gets the role that invitee has been invited to the site as
*
* @return the role that the invitee has been invited to the site as
*/
public String getRole()
{
return role;
}
}

View File

@@ -31,7 +31,6 @@ import java.util.List;
import java.util.Map;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.repo.site.SiteService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PersonService;
@@ -77,12 +76,16 @@ public class Invites extends DeclarativeWebScript
// model key names
private static final String MODEL_KEY_NAME_INVITES = "invites";
// invitation statuses
private static final String INVITATION_STATUS_PENDING = "pending";
private static final String INVITATION_STATUS_ACCEPTED = "accepted";
private static final String INVITATION_STATUS_REJECTED = "rejected";
// service instances
private WorkflowService workflowService;
private NamespaceService namespaceService;
private PersonService personService;
private SiteService siteService;
private ServiceRegistry serviceRegistry;
/**
@@ -115,10 +118,6 @@ public class Invites extends DeclarativeWebScript
this.serviceRegistry = serviceRegistry;
}
public void setSiteService(SiteService siteService) {
this.siteService = siteService;
}
/*
* (non-Javadoc)
*
@@ -261,14 +260,16 @@ public class Invites extends DeclarativeWebScript
// as "inviteId" onto model
String workflowId = workflowTask.path.instance.id;
// TODO: fetch correct workflow start date
Date sentInviteDate = new Date();
// set the invite start date to the time the workflow instance
// (associated with the task) was started
Date sentInviteDate = workflowTask.path.instance.startDate;
// TODO: fetchh correct role
String role = "SiteManager";
// get role that invitee was invited to the site as
String role = InviteHelper.getInviteeSiteRoleFromInvite(inviteId, workflowService, namespaceService);
// TODO: assign correct state
String invitationStatus = "pending"; // "accepted", "declined"
// TODO: glen johnson at alfresco com - as this web script only returns
// pending invites, this is hard coded to "pending" for now
String invitationStatus = INVITATION_STATUS_PENDING;
// check whether we can find a person node for inviter/invitee
NodeRef inviterRef = personService.getPerson(inviterUserNameProp);