Cleanup of JavaScript code formatting in Groups REST API.

Also fix up nonsense tags in related WebScript description fields.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-06-17 12:40:49 +00:00
parent 423da7eb22
commit ad05edcbe9
14 changed files with 230 additions and 227 deletions

View File

@@ -4,7 +4,7 @@
Remove an authority (USER or GROUP) from a group. A user will not be deleted by this method.
<br />
You must have "administrator" privileges to alter a group.
</br />
<br />
]]>
</description>
<url>/api/groups/{shortGroupName}/children/{fullAuthorityName}</url>

View File

@@ -1,22 +1,22 @@
/**
* remove authority from group
* Remove authority from group
*/
function main ()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var fullAuthorityName = urlElements[2];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
group.removeAuthority(fullAuthorityName);
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var fullAuthorityName = urlElements[2];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
group.removeAuthority(fullAuthorityName);
}
main();
main();

View File

@@ -1,42 +1,44 @@
// get children
function main ()
{
/**
* Get children
*/
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var authorityType = args["authorityType"];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
model.group = group;
if(authorityType != null)
{
if(!authorityType.match("[GROUP|USER]"))
{
status.setCode(status.STATUS_BAD_REQUEST, "The authorityType argument has does not have a correct value.");
return;
}
if(authorityType == "GROUP")
{
model.children = group.getChildGroups();
}
if(authorityType == "USER")
{
model.children = group.getChildUsers();
}
}
else
{
model.children = group.getChildAuthorities();
}
function main()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var authorityType = args["authorityType"];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
model.group = group;
if (authorityType != null)
{
if (!authorityType.match("[GROUP|USER]"))
{
status.setCode(status.STATUS_BAD_REQUEST, "The authorityType argument has does not have a correct value.");
return;
}
if (authorityType == "GROUP")
{
model.children = group.getChildGroups();
}
if (authorityType == "USER")
{
model.children = group.getChildUsers();
}
}
else
{
model.children = group.getChildAuthorities();
}
}
main();

View File

@@ -1,46 +1,45 @@
/**
* Link groups or users to group.
*
* Will create sub-groups if they don't already exist.
*/
* Link groups or users to group.
*
* Will create sub-groups if they don't already exist.
*/
function main ()
function main()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var fullAuthorityName = urlElements[2];
var group = groups.getGroup(shortName);
var GROUP_PREFIX = "GROUP_";
if (group == null)
{
// Parent Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
if (fullAuthorityName.match("^" + GROUP_PREFIX + "*"))
{
var subGroupName = fullAuthorityName.substr(GROUP_PREFIX.length);
var child = groups.getGroup(subGroupName);
// This is a group authority
if(child == null)
{
// child does not exist
child = group.createGroup(subGroupName, subGroupName);
status.code = status.STATUS_CREATED;
model.group = child;
return;
}
}
// Link an existing group or user
group.addAuthority(fullAuthorityName);
status.code = status.STATUS_OK;
model.group
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var fullAuthorityName = urlElements[2];
var group = groups.getGroup(shortName);
var GROUP_PREFIX = "GROUP_";
if (group == null)
{
// Parent Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
if (fullAuthorityName.match("^" + GROUP_PREFIX + "*"))
{
var subGroupName = fullAuthorityName.substr(GROUP_PREFIX.length);
var child = groups.getGroup(subGroupName);
// This is a group authority
if(child == null)
{
// child does not exist
child = group.createGroup(subGroupName, subGroupName);
status.code = status.STATUS_CREATED;
model.group = child;
return;
}
}
// Link an existing group or user
group.addAuthority(fullAuthorityName);
status.code = status.STATUS_OK;
model.group
}
main();

View File

@@ -2,20 +2,20 @@
* Get group
*/
function main ()
function main()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
model.group = group;
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
model.group = group;
}
main();

View File

@@ -1,26 +1,26 @@
// update group
/**
* Update group
*/
function main ()
function main()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
if (json.has("displayName") == true)
{
group.setDisplayName(json.get("displayName"));
}
model.group = group;
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
if (json.has("displayName") == true)
{
group.setDisplayName(json.get("displayName"));
}
model.group = group;
}
main();
main();

View File

@@ -4,7 +4,7 @@
Delete a group and all its dependents.
<br />
You must have "administrator" privileges to delete a group.
</br />
<br />
]]>
</description>
<url>/api/groups/{shortName}</url>

View File

@@ -1,21 +1,21 @@
// delete group
/**
* Delete group
*/
function main ()
function main()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
group.deleteGroup();
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
group.deleteGroup();
}
main();
main();

View File

@@ -1,6 +1,6 @@
/**
* List/Search groups
*/
*/
function main ()
{

View File

@@ -1,34 +1,37 @@
// get parents
/**
* Get parent groups
*/
function main ()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var level = args["level"];
var group = groups.getGroup(shortName);
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var level = args["level"];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group: " + shortName + " does not exist.");
return;
}
model.group = group;
if (level != null)
{
if (!level.match("[ALL]"))
{
status.setCode(status.STATUS_BAD_REQUEST, "The level argument has does not have a correct value.");
return;
}
model.parents = group.getAllParentGroups();
}
else
{
model.parents = group.getParentGroups();
}
model.group = group;
if (level != null)
{
if (!level.match("[ALL]"))
{
status.setCode(status.STATUS_BAD_REQUEST, "The level argument has does not have a correct value.");
return;
}
model.parents = group.getAllParentGroups();
}
else
{
model.parents = group.getParentGroups();
}
}
main();

View File

@@ -4,7 +4,7 @@
Delete a root group and all its dependents.
<br />
You must have "administrator" privileges to delete a group.
</br />
<br />
]]>
</description>
<url>/api/rootgroups/{shortName}</url>

View File

@@ -1,21 +1,21 @@
// delete group
/**
* Delete group
*/
function main ()
function main()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
group.deleteGroup();
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group == null)
{
// Group cannot be found
status.setCode(status.STATUS_NOT_FOUND, "The group :" + shortName + ", does not exist.");
return;
}
group.deleteGroup();
}
main();
main();

View File

@@ -4,22 +4,19 @@
function main ()
{
// Get the args
var shortNameFilter = args["shortNameFilter"];
var includeInternalStr = args["includeInternal"];
if(shortNameFilter == null)
{
shortNameFilter = "";
}
var includeInternal = includeInternalStr == "true" ? true : false;
// Do the search
model.groups = groups.searchRootGroups(shortNameFilter, includeInternal);
// Get the args
var shortNameFilter = args["shortNameFilter"];
var includeInternalStr = args["includeInternal"];
if (shortNameFilter == null)
{
shortNameFilter = "";
}
var includeInternal = includeInternalStr == "true" ? true : false;
// Do the search
model.groups = groups.searchRootGroups(shortNameFilter, includeInternal);
}
main();
main();

View File

@@ -1,27 +1,29 @@
// Create new rootgroup.
/**
* Create new root group.
*/
function main ()
function main()
{
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group != null)
{
// Group already exists
status.setCode(status.STATUS_BAD_REQUEST, "The root group :" + shortName + ", already exixts.");
return;
}
var displayName = shortName;
if (json.has("displayName") == true)
{
displayName = json.get("displayName");
}
model.group = groups.createRootGroup(shortName, displayName);
status.code = status.STATUS_CREATED;
var urlElements = url.extension.split("/");
var shortName = urlElements[0];
var group = groups.getGroup(shortName);
if (group != null)
{
// Group already exists
status.setCode(status.STATUS_BAD_REQUEST, "The root group :" + shortName + ", already exixts.");
return;
}
var displayName = shortName;
if (json.has("displayName") == true)
{
displayName = json.get("displayName");
}
model.group = groups.createRootGroup(shortName, displayName);
status.code = status.STATUS_CREATED;
}
main();