- changed accept/reject webscripts to put method

- some code cleanup / removed obsolete invite.get.html.ftl

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10515 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Michael Ru
2008-08-26 09:53:05 +00:00
parent a3c4c70d3e
commit 0cbea60cf6
8 changed files with 13 additions and 65 deletions

View File

@@ -1,7 +0,0 @@
<#if action == "start">
<p>Invite to join site ${siteShortName} has been sent to ${inviteeUserName}</p>
<#elseif action == "cancel">
<p>Invite with ID ${inviteId} has been cancelled</p>
<#else>
<p>Error: unknown invite action ${action}</p>
</#if>

View File

@@ -1,8 +0,0 @@
<webscript>
<shortname>Invite reject</shortname>
<description>Rejects an invite</description>
<url>/api/invite/{inviteId}/{inviteTicket}</url>
<format default="json"/>
<authentication>none</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -1,4 +0,0 @@
{
"response" : "${response}",
"siteShortName" : "${siteShortName}"
}

View File

@@ -1,7 +1,7 @@
<webscript>
<shortname>Invite accept</shortname>
<description>Accepts an invite</description>
<url>/api/invite/{inviteId}/{inviteTicket}</url>
<url>/api/invite/{inviteId}/{inviteTicket}/{action}</url>
<format default="json"/>
<authentication>none</authentication>
<transaction>required</transaction>

View File

@@ -301,7 +301,7 @@
</bean>
<!-- -->
<!-- Invite Accept Web Script - accepts a pending invite -->
<!-- Invite Accept/Reject Web Script - accepts or rejects a pending invite -->
<!-- -->
<bean id="webscript.org.alfresco.repository.invite.inviteresponse.put"
@@ -313,19 +313,6 @@
<property name="personService" ref="personService"/>
</bean>
<!-- -->
<!-- Invite Reject Web Script - rejects a pending invite -->
<!-- -->
<bean id="webscript.org.alfresco.repository.invite.inviteresponse.delete"
class="org.alfresco.repo.web.scripts.invite.InviteResponse"
parent="webscript">
<property name="workflowService" ref="workflowServiceImpl"/>
<property name="mutableAuthenticationDao" ref="authenticationDao"/>
<property name="siteService" ref="siteService"/>
<property name="personService" ref="personService"/>
</bean>
<!-- -->
<!-- Invites Web Script (pending invites) - returns pending invites matching the given -->
<!-- inviter user name, invitee user name, site short name, or invite ID URL request parameters -->

View File

@@ -86,17 +86,9 @@ public class InviteByTicket extends DeclarativeWebScript
// initialise model to pass on for template to render
Map<String, Object> model = new HashMap<String, Object>();
// Extract inviteId and inviteTicket
String extPath = req.getExtensionPath();
int separatorIndex = extPath.indexOf('/');
if (separatorIndex < 0)
{
// should not happen as descriptor would not match
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
"Parameters missing");
}
String inviteId = extPath.substring(0, separatorIndex);
String inviteTicket = extPath.substring(separatorIndex + 1);
// get inviteId and inviteTicket
String inviteId = req.getServiceMatch().getTemplateVars().get("inviteId");
String inviteTicket = req.getServiceMatch().getTemplateVars().get("inviteTicket");
// authenticate as system for the rest of the webscript
AuthenticationUtil.setSystemUserAsCurrentUser();

View File

@@ -156,18 +156,6 @@ public class InviteResponse extends DeclarativeWebScript
{
// initialise model to pass on for template to render
Map<String, Object> model = new HashMap<String, Object>();
// Extract inviteId and inviteTicket
/*String extPath = req.getExtensionPath();
int separatorIndex = extPath.indexOf('/');
if (separatorIndex < 0)
{
// should not happen as descriptor would not match
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
"Parameters missing");
}
String inviteId = extPath.substring(0, separatorIndex);
String inviteTicket = extPath.substring(separatorIndex + 1);*/
String inviteId = req.getServiceMatch().getTemplateVars().get("inviteId");
String inviteTicket = req.getServiceMatch().getTemplateVars().get("inviteTicket");
@@ -189,12 +177,12 @@ public class InviteResponse extends DeclarativeWebScript
}
// process response
String method = req.getServiceMatch().getWebScript().getDescription().getMethod();
if (method.equals("PUT"))
String action = req.getServiceMatch().getTemplateVars().get("action");
if (action.equals("accept"))
{
acceptInvite(model, inviteId, inviteStartTask);
}
else if (method.equals("DELETE"))
else if (action.equals("reject"))
{
rejectInvite(model, inviteId, inviteStartTask);
}
@@ -202,7 +190,7 @@ public class InviteResponse extends DeclarativeWebScript
{
/* handle unrecognised method */
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
"method " + method + " is not supported by this webscript.");
"action " + action + " is not supported by this webscript.");
}
return model;

View File

@@ -501,7 +501,7 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteeUserName = result.getString("inviteeUserName");
// Invitee accepts invitation to a Site from Inviter
String acceptInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket;
String acceptInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket + "/accept";
MockHttpServletResponse response = putRequest(acceptInviteUrl,
Status.STATUS_OK, null, null);
@@ -535,9 +535,9 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteeUserName = result.getString("inviteeUserName");
// Invitee rejects invitation to a Site from Inviter
String rejectInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket;
MockHttpServletResponse response = deleteRequest(rejectInviteUrl,
Status.STATUS_OK);
String rejectInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket + "/reject";
MockHttpServletResponse response = putRequest(rejectInviteUrl,
Status.STATUS_OK, null, null);
//
// test that invite represented by invite ID (of invitation started