mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix to Invite REST API where inviteeUserName arg was not correctly checked when inviting external users.
Also cleanup the related .js scripts to use spaces not tabs - significantly aids debugging in the script debugger. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13913 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,42 +1,41 @@
|
||||
/**
|
||||
* List/Search invitations implementation
|
||||
*/
|
||||
|
||||
function main ()
|
||||
function main()
|
||||
{
|
||||
// Get the site id
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
|
||||
// Get the args
|
||||
var inviteeUserName = args["inviteeUserName"];
|
||||
var invitationType = args["invitationType"];
|
||||
var resourceType = args["resourceType"];
|
||||
var resourceName = args["resourceName"];
|
||||
|
||||
var props = {};
|
||||
|
||||
if(inviteeUserName != null)
|
||||
{
|
||||
props.inviteeUserName = inviteeUserName
|
||||
}
|
||||
if(invitationType != null)
|
||||
{
|
||||
props.invitationType = invitationType
|
||||
}
|
||||
if(resourceType != null)
|
||||
{
|
||||
props.resourceType = resourceType
|
||||
}
|
||||
if(resourceName != null)
|
||||
{
|
||||
props.resourceName = resourceName
|
||||
}
|
||||
|
||||
var invites = invitations.listInvitations(props);
|
||||
|
||||
// Pass the information to the template
|
||||
model.invitations = invites;
|
||||
// Get the site id
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
|
||||
// Get the args
|
||||
var inviteeUserName = args["inviteeUserName"];
|
||||
var invitationType = args["invitationType"];
|
||||
var resourceType = args["resourceType"];
|
||||
var resourceName = args["resourceName"];
|
||||
|
||||
var props = {};
|
||||
|
||||
if (inviteeUserName != null)
|
||||
{
|
||||
props.inviteeUserName = inviteeUserName
|
||||
}
|
||||
if (invitationType != null)
|
||||
{
|
||||
props.invitationType = invitationType
|
||||
}
|
||||
if (resourceType != null)
|
||||
{
|
||||
props.resourceType = resourceType
|
||||
}
|
||||
if (resourceName != null)
|
||||
{
|
||||
props.resourceName = resourceName
|
||||
}
|
||||
|
||||
var invites = invitations.listInvitations(props);
|
||||
|
||||
// Pass the information to the template
|
||||
model.invitations = invites;
|
||||
}
|
||||
|
||||
main();
|
||||
main();
|
@@ -1,33 +1,33 @@
|
||||
// Cancel invitation for a web site
|
||||
|
||||
/**
|
||||
* Cancel invitation for a web site
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
// Get the url values
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
var inviteId = urlElements[2];
|
||||
|
||||
// Get the site
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Need to cancel an invitation here
|
||||
var invitation = site.getInvitation(inviteId);
|
||||
if (invitation == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel the invitation
|
||||
invitation.cancel();
|
||||
// Get the url values
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
var inviteId = urlElements[2];
|
||||
|
||||
// Get the site
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Need to cancel an invitation here
|
||||
var invitation = site.getInvitation(inviteId);
|
||||
if (invitation == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel the invitation
|
||||
invitation.cancel();
|
||||
}
|
||||
|
||||
main();
|
@@ -3,32 +3,30 @@
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
|
||||
// Get the site id
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
var inviteId = urlElements[2];
|
||||
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var invitation = site.getInvitation(inviteId);
|
||||
if (invitation == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the site id
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
var inviteId = urlElements[2];
|
||||
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var invitation = site.getInvitation(inviteId);
|
||||
if (invitation == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass the model to the template
|
||||
model.invitation = invitation;
|
||||
model.site = site;
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
|
||||
main();
|
@@ -3,137 +3,132 @@
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
|
||||
var invitation = null;
|
||||
|
||||
// Get the web site site
|
||||
var shortName = url.extension.split("/")[0];
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!json.has("invitationType"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the role
|
||||
var invitationType = json.get("invitationType");
|
||||
if (invitationType == null || invitationType.length == 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType is null or empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!invitationType.match("[MODERATED]|[NOMINATED]"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has does not have a correct value.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(invitationType == "MODERATED")
|
||||
{
|
||||
// Check mandatory parameters
|
||||
if(!json.has("inviteeRoleName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!json.has("inviteeUserName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeUserName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the role
|
||||
var inviteeRoleName = json.get("inviteeRoleName");
|
||||
if (inviteeRoleName == null || inviteeRoleName == "")
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
var inviteeComments = json.get("inviteeComments");
|
||||
if (inviteeComments == null)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeComments has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
var inviteeUserName = json.get("inviteeUserName");
|
||||
if (inviteeUserName == null || inviteeUserName == "")
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The userName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
invitation = site.inviteModerated(inviteeComments, inviteeUserName, inviteeRoleName);
|
||||
}
|
||||
|
||||
if(invitationType == "NOMINATED")
|
||||
{
|
||||
|
||||
// Get Mandatory properties
|
||||
if(!json.has("inviteeRoleName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||
return;
|
||||
}
|
||||
var inviteeRoleName = json.get("inviteeRoleName");
|
||||
if (inviteeRoleName == null || inviteeRoleName == "" )
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName is null or empty.");
|
||||
return;
|
||||
}
|
||||
var serverPath = json.get("serverPath");
|
||||
var acceptUrl = json.get("acceptURL");
|
||||
var rejectUrl = json.get("rejectURL");
|
||||
|
||||
/**
|
||||
* Get the optional properties
|
||||
*/
|
||||
if(json.has("inviteeUserName"))
|
||||
{
|
||||
var inviteeUserName = json.get("inviteeUserName");
|
||||
invitation = site.inviteNominated(inviteeUserName, inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get Mandatory properties
|
||||
if(!json.has("inviteeFirstName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeFirstName has not been set.");
|
||||
return;
|
||||
}
|
||||
if(!json.has("inviteeLastName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeLastName has not been set.");
|
||||
return;
|
||||
}
|
||||
if(!json.has("inviteeEmail"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeEmail has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
var inviteeFirstName = json.get("inviteeFirstName") ;
|
||||
var inviteeLastName = json.get("inviteeLastName") ;
|
||||
var inviteeEmail = json.get("inviteeEmail") ;
|
||||
invitation = site.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// Pass the model to the results template
|
||||
model.site = site;
|
||||
model.invitation = invitation;
|
||||
|
||||
status.code = status.STATUS_CREATED;
|
||||
var invitation = null;
|
||||
|
||||
// Get the web site site
|
||||
var shortName = url.extension.split("/")[0];
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json.has("invitationType"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the role
|
||||
var invitationType = json.get("invitationType");
|
||||
if (invitationType == null || invitationType.length == 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType is null or empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!invitationType.match("[MODERATED]|[NOMINATED]"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has does not have a correct value.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (invitationType == "MODERATED")
|
||||
{
|
||||
// Check mandatory parameters
|
||||
if (!json.has("inviteeRoleName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json.has("inviteeUserName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeUserName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the role
|
||||
var inviteeRoleName = json.get("inviteeRoleName");
|
||||
if (inviteeRoleName == null || inviteeRoleName == "")
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
var inviteeComments = json.get("inviteeComments");
|
||||
if (inviteeComments == null)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeComments has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
var inviteeUserName = json.get("inviteeUserName");
|
||||
if (inviteeUserName == null || inviteeUserName == "")
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The userName has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
invitation = site.inviteModerated(inviteeComments, inviteeUserName, inviteeRoleName);
|
||||
}
|
||||
|
||||
if (invitationType == "NOMINATED")
|
||||
{
|
||||
// Get mandatory properties
|
||||
if (!json.has("inviteeRoleName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||
return;
|
||||
}
|
||||
var inviteeRoleName = json.get("inviteeRoleName");
|
||||
if (inviteeRoleName == null || inviteeRoleName == "")
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName is null or empty.");
|
||||
return;
|
||||
}
|
||||
var serverPath = json.get("serverPath");
|
||||
var acceptUrl = json.get("acceptURL");
|
||||
var rejectUrl = json.get("rejectURL");
|
||||
|
||||
// Get the optional properties
|
||||
if (json.has("inviteeUserName") && json.get("inviteeUserName") != "")
|
||||
{
|
||||
invitation = site.inviteNominated(json.get("inviteeUserName"), inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get mandatory properties
|
||||
if (!json.has("inviteeFirstName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeFirstName has not been set.");
|
||||
return;
|
||||
}
|
||||
if (!json.has("inviteeLastName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeLastName has not been set.");
|
||||
return;
|
||||
}
|
||||
if (!json.has("inviteeEmail"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeEmail has not been set.");
|
||||
return;
|
||||
}
|
||||
|
||||
var inviteeFirstName = json.get("inviteeFirstName") ;
|
||||
var inviteeLastName = json.get("inviteeLastName") ;
|
||||
var inviteeEmail = json.get("inviteeEmail") ;
|
||||
invitation = site.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// Pass the model to the results template
|
||||
model.site = site;
|
||||
model.invitation = invitation;
|
||||
|
||||
status.code = status.STATUS_CREATED;
|
||||
}
|
||||
|
||||
main();
|
@@ -1,40 +1,39 @@
|
||||
/**
|
||||
* List invitations implementation
|
||||
*/
|
||||
|
||||
*/
|
||||
function main ()
|
||||
{
|
||||
// Get the site id
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
|
||||
// Get the args
|
||||
var inviteeUserName = args["inviteeUserName"];
|
||||
var invitationType = args["invitationType"];
|
||||
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var props = {};
|
||||
|
||||
if(inviteeUserName != null)
|
||||
{
|
||||
props.inviteeUserName = inviteeUserName
|
||||
}
|
||||
if(invitationType != null)
|
||||
{
|
||||
props.invitationType = invitationType
|
||||
}
|
||||
|
||||
var invitations = site.listInvitations(props);
|
||||
|
||||
// Pass the information to the template
|
||||
model.invitations = invitations;
|
||||
// Get the site id
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
|
||||
// Get the args
|
||||
var inviteeUserName = args["inviteeUserName"];
|
||||
var invitationType = args["invitationType"];
|
||||
|
||||
var site = siteService.getSite(shortName);
|
||||
if (site == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var props = {};
|
||||
|
||||
if (inviteeUserName != null)
|
||||
{
|
||||
props.inviteeUserName = inviteeUserName
|
||||
}
|
||||
if (invitationType != null)
|
||||
{
|
||||
props.invitationType = invitationType
|
||||
}
|
||||
|
||||
var invitations = site.listInvitations(props);
|
||||
|
||||
// Pass the information to the template
|
||||
model.invitations = invitations;
|
||||
}
|
||||
|
||||
main();
|
||||
main();
|
Reference in New Issue
Block a user