mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Added invitee first name and last name parameters to the "/api/invite/start" web script call for the Invite Service
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9831 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Invite</shortname>
|
||||
<description>Processes Inviter actions ('start' or 'cancel' invite)</description>
|
||||
<url>/api/invite/start?inviteeEmail={inviteeEmailAddress}&siteShortName={siteShortName}</url>
|
||||
<url>/api/invite/start?inviteeFirstName={inviteeFirstName}&inviteeLastName={inviteeLastName}&inviteeEmail={inviteeEmailAddress}&siteShortName={siteShortName}</url>
|
||||
<url>/api/invite/cancel?inviteId={inviteId}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
|
@@ -10,6 +10,21 @@
|
||||
<#else>
|
||||
"inviteeUserName" : undefined,
|
||||
</#if>
|
||||
<#if inviteeFirstName??>
|
||||
"inviteeFirstName" : "${inviteeFirstName}",
|
||||
<#else>
|
||||
"inviteeFirstName" : undefined,
|
||||
</#if>
|
||||
<#if inviteeLastName??>
|
||||
"inviteeLastName" : "${inviteeLastName}",
|
||||
<#else>
|
||||
"inviteeLastName" : undefined,
|
||||
</#if>
|
||||
<#if inviteeEmail??>
|
||||
"inviteeEmail" : "${inviteeEmail}",
|
||||
<#else>
|
||||
"inviteeEmail" : undefined,
|
||||
</#if>
|
||||
<#if siteShortName??>
|
||||
"siteShortName" : "${siteShortName}"
|
||||
<#else>
|
||||
|
@@ -66,9 +66,14 @@ public class Invite extends DeclarativeWebScript
|
||||
private static final String MODEL_PROP_KEY_ACTION = "action";
|
||||
private static final String MODEL_PROP_KEY_INVITE_ID = "inviteId";
|
||||
private static final String MODEL_PROP_KEY_INVITEE_USER_NAME = "inviteeUserName";
|
||||
private static final String MODEL_PROP_KEY_INVITEE_FIRSTNAME = "inviteeFirstName";
|
||||
private static final String MODEL_PROP_KEY_INVITEE_LASTNAME = "inviteeLastName";
|
||||
private static final String MODEL_PROP_KEY_INVITEE_EMAIL = "inviteeEmail";
|
||||
private static final String MODEL_PROP_KEY_SITE_SHORT_NAME = "siteShortName";
|
||||
|
||||
// URL request parameter names
|
||||
private static final String PARAM_INVITEE_FIRSTNAME = "inviteeFirstName";
|
||||
private static final String PARAM_INVITEE_LASTNAME = "inviteeLastName";
|
||||
private static final String PARAM_INVITEE_EMAIL = "inviteeEmail";
|
||||
private static final String PARAM_SITE_SHORT_NAME = "siteShortName";
|
||||
private static final String PARAM_INVITE_ID = "inviteId";
|
||||
@@ -227,6 +232,28 @@ public class Invite extends DeclarativeWebScript
|
||||
// handle action 'start'
|
||||
if (action.equals(ACTION_START))
|
||||
{
|
||||
// check for 'inviteeFirstName' parameter not provided
|
||||
String inviteeFirstName = req.getParameter(PARAM_INVITEE_FIRSTNAME);
|
||||
if ((inviteeFirstName == null) || (inviteeFirstName.length() == 0))
|
||||
{
|
||||
// handle inviteeFirstName URL parameter not provided
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||
"'inviteeFirstName' parameter "
|
||||
+ "has not been provided in URL for action '"
|
||||
+ ACTION_START + "'");
|
||||
}
|
||||
|
||||
// check for 'inviteeLastName' parameter not provided
|
||||
String inviteeLastName = req.getParameter(PARAM_INVITEE_LASTNAME);
|
||||
if ((inviteeLastName == null) || (inviteeLastName.length() == 0))
|
||||
{
|
||||
// handle inviteeLastName URL parameter not provided
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||
"'inviteeLastName' parameter "
|
||||
+ "has not been provided in URL for action '"
|
||||
+ ACTION_START + "'");
|
||||
}
|
||||
|
||||
// check for 'inviteeEmail' parameter not provided
|
||||
String inviteeEmail = req.getParameter(PARAM_INVITEE_EMAIL);
|
||||
if ((inviteeEmail == null) || (inviteeEmail.length() == 0))
|
||||
@@ -250,7 +277,7 @@ public class Invite extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
// process action 'start' with provided parameters
|
||||
startInvite(model, inviteeEmail, siteShortName);
|
||||
startInvite(model, inviteeFirstName, inviteeLastName, inviteeEmail, siteShortName);
|
||||
}
|
||||
// else handle if provided 'action' is 'cancel'
|
||||
else if (action.equals(ACTION_CANCEL))
|
||||
@@ -286,6 +313,10 @@ public class Invite extends DeclarativeWebScript
|
||||
* @param model
|
||||
* model to add objects to, which will be passed to the template
|
||||
* for rendering
|
||||
* @param inviteeFirstName
|
||||
* first name of invitee
|
||||
* @param inviteeLastNamme
|
||||
* last name of invitee
|
||||
* @param inviteeEmail
|
||||
* email address of invitee
|
||||
* @param siteShortName
|
||||
@@ -293,8 +324,8 @@ public class Invite extends DeclarativeWebScript
|
||||
* inviter
|
||||
*
|
||||
*/
|
||||
private void startInvite(Map<String, Object> model, String inviteeEmail,
|
||||
String siteShortName)
|
||||
private void startInvite(Map<String, Object> model, String inviteeFirstName, String inviteeLastName,
|
||||
String inviteeEmail, String siteShortName)
|
||||
{
|
||||
// get the inviter user name (the name of user web script is executed under)
|
||||
// - needs to be assigned here because various system calls further on
|
||||
@@ -323,6 +354,8 @@ public class Invite extends DeclarativeWebScript
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
|
||||
properties.put(ContentModel.PROP_USERNAME, inviteeUserName);
|
||||
properties.put(ContentModel.PROP_FIRSTNAME, inviteeFirstName);
|
||||
properties.put(ContentModel.PROP_LASTNAME, inviteeLastName);
|
||||
properties.put(ContentModel.PROP_EMAIL, inviteeEmail);
|
||||
|
||||
this.personService.createPerson(properties);
|
||||
@@ -403,6 +436,9 @@ public class Invite extends DeclarativeWebScript
|
||||
model.put(MODEL_PROP_KEY_ACTION, ACTION_START);
|
||||
model.put(MODEL_PROP_KEY_INVITE_ID, workflowId);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_USER_NAME, inviteeUserName);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_FIRSTNAME, inviteeFirstName);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_LASTNAME, inviteeLastName);
|
||||
model.put(MODEL_PROP_KEY_INVITEE_EMAIL, inviteeEmail);
|
||||
model.put(MODEL_PROP_KEY_SITE_SHORT_NAME, siteShortName);
|
||||
}
|
||||
|
||||
|
@@ -51,6 +51,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
|
||||
private static final String USER_ADMIN = "admin";
|
||||
private static final String USER_INVITER = "InviteeUser";
|
||||
private static final String INVITEE_FIRSTNAME = "InviteeFirstName";
|
||||
private static final String INVITEE_LASTNAME = "InviteeLastName";
|
||||
private static final String INVITEE_EMAIL = "inviter123@email.com";
|
||||
private static final String SITE_SHORT_NAME_INVITE = "InviteSiteShortName";
|
||||
|
||||
@@ -145,15 +147,14 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject startInvite(String inviteeEmail, String siteShortName,
|
||||
int expectedStatus) throws Exception
|
||||
private JSONObject startInvite(String inviteeFirstName, String inviteeLastName, String inviteeEmail,
|
||||
String siteShortName, int expectedStatus) throws Exception
|
||||
{
|
||||
// Inviter sends invitation to Invitee to join a Site
|
||||
String startInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_START
|
||||
+ "?inviteeEmail=" + inviteeEmail + "&siteShortName="
|
||||
+ siteShortName;
|
||||
MockHttpServletResponse response = getRequest(startInviteUrl,
|
||||
expectedStatus);
|
||||
+ "?inviteeFirstName=" + inviteeFirstName + "&inviteeLastName=" + inviteeLastName
|
||||
+ "&inviteeEmail=" + inviteeEmail + "&siteShortName=" + siteShortName;
|
||||
MockHttpServletResponse response = getRequest(startInviteUrl, expectedStatus);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
|
||||
@@ -222,18 +223,21 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
|
||||
public void testStartInvite() throws Exception
|
||||
{
|
||||
JSONObject result = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
assertEquals(INVITE_ACTION_START, result.get("action"));
|
||||
assertEquals(INVITEE_FIRSTNAME, result.get("inviteeFirstName"));
|
||||
assertEquals(INVITEE_LASTNAME, result.get("inviteeLastName"));
|
||||
assertEquals(INVITEE_EMAIL, result.get("inviteeEmail"));
|
||||
assertEquals(SITE_SHORT_NAME_INVITE, result.get("siteShortName"));
|
||||
}
|
||||
|
||||
public void testCancelInvite() throws Exception
|
||||
{
|
||||
// inviter starts invite workflow
|
||||
JSONObject result = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
// get hold of invite ID of started invite
|
||||
String inviteId = result.getString("inviteId");
|
||||
@@ -248,8 +252,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
public void testAcceptInvite() throws Exception
|
||||
{
|
||||
// inviter starts invite (sends out invitation)
|
||||
JSONObject result = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
// get hold of invite ID of started invite
|
||||
String inviteId = result.getString("inviteId");
|
||||
@@ -270,8 +274,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
public void testRejectInvite() throws Exception
|
||||
{
|
||||
// inviter starts invite (sends out invitation)
|
||||
JSONObject result = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
// get hold of invite ID of started invite
|
||||
String inviteId = result.getString("inviteId");
|
||||
@@ -292,8 +296,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
public void testGetInvitesByInviteId() throws Exception
|
||||
{
|
||||
// inviter starts invite workflow
|
||||
JSONObject startInviteResult = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
// get hold of workflow ID of started invite workflow instance
|
||||
|
||||
@@ -314,8 +318,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
public void testGetInvitesByInviterUserName() throws Exception
|
||||
{
|
||||
// inviter starts invite workflow
|
||||
JSONObject startInviteResult = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
// get pending invites matching inviter user name used in invite started above
|
||||
JSONArray getInvitesResult = getInvitesByInviterUserName(USER_INVITER, Status.STATUS_OK);
|
||||
@@ -330,8 +334,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
public void testGetInvitesByInviteeUserName() throws Exception
|
||||
{
|
||||
// inviter starts invite workflow
|
||||
JSONObject startInviteResult = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
// get hold of invitee user name property of started invite workflow instance
|
||||
String inviteeUserName = startInviteResult.getString("inviteeUserName");
|
||||
@@ -351,8 +355,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
||||
public void testGetInvitesBySiteShortName() throws Exception
|
||||
{
|
||||
// inviter starts invite workflow
|
||||
JSONObject startInviteResult = startInvite(INVITEE_EMAIL, SITE_SHORT_NAME_INVITE,
|
||||
Status.STATUS_OK);
|
||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||
|
||||
// get hold of site short name property of started invite workflow instance
|
||||
String siteShortName = startInviteResult.getString("siteShortName");
|
||||
|
Reference in New Issue
Block a user