mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge WCM_SERVICES into HEAD 11697, 11698, 11702, 11751, 11801, 11924, 12023, 12073
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12076 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
<description>Delete (uninvite) the membership for a user.
|
||||
Sandboxes are deleted even if they have unsubmitted content.
|
||||
</description>
|
||||
<url>/api/wcm/webproject/{webprojectref}/membership/{username}</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/memberships/{username}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,8 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>Membership</shortname>
|
||||
<description>Get the webproject membership details for a user</description>
|
||||
<url>/api/wcm/webproject/{webprojectref}/membership/{username}</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/memberships/{username}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,2 +1,4 @@
|
||||
<#import "membership.lib.ftl" as membershipLib/>
|
||||
<@membershipLib.membershipJSON webproject=webproject role=role person=person/>
|
||||
{
|
||||
data:<@membershipLib.membershipJSON webproject=webproject role=role person=person/>
|
||||
}
|
@@ -1,8 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>Memberships</shortname>
|
||||
<description>Get a collection of a web project memberships.</description>
|
||||
<url>/api/wcm/webproject/{webprojectref}/memberships</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/memberships</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,5 +1,6 @@
|
||||
<#import "membership.lib.ftl" as membershipLib/>
|
||||
[
|
||||
{
|
||||
data:[
|
||||
<#if memberships??>
|
||||
<#assign userNames = memberships?keys />
|
||||
<#list userNames as userName>
|
||||
@@ -8,4 +9,4 @@
|
||||
</#list>
|
||||
</#if>
|
||||
]
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>Invite user to web project</shortname>
|
||||
<description>Adds a new membership to the web project</description>
|
||||
<url>/api/wcm/webproject/{webprojectref}/memberships</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/memberships</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,2 +1,4 @@
|
||||
<#import "membership.lib.ftl" as membershipLib/>
|
||||
<@membershipLib.membershipJSON webproject=webproject role=role person=person/>
|
||||
{
|
||||
data:<@membershipLib.membershipJSON webproject=webproject role=role person=person/>
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<#macro assetJSON asset>
|
||||
{
|
||||
"path" : <#escape x as jsonUtils.encodeJSONString(x)> "${asset.path}" </#escape>,
|
||||
"name" : <#escape x as jsonUtils.encodeJSONString(x)> "${asset.name}" </#escape>,
|
||||
"creator" : <#escape x as jsonUtils.encodeJSONString(x)> "${asset.creator}" </#escape>,
|
||||
"createdDate" : { "iso8601" : "${sandbox.createdDateAsISO8601}" },
|
||||
"modifier" : <#escape x as jsonUtils.encodeJSONString(x)> "${asset.modifier}" </#escape>,
|
||||
"isFile" : ${asset.file?string("true", "false")},
|
||||
"isDirectory" : ${asset.directory?string("true", "false")},
|
||||
"isDeleted" : ${asset.deleted?string("true", "false")}
|
||||
}
|
||||
</#macro>
|
@@ -0,0 +1,18 @@
|
||||
<webscript>
|
||||
<shortname>Get modified assets within the specified sandbox.</shortname>
|
||||
<description>
|
||||
<![CDATA[
|
||||
Get the modified (added, deleted, updated) asset properties of an author's sandbox.
|
||||
<BR>
|
||||
If a directory has been added then only the directory's properties are returned (not directory plus assets within that new directory).
|
||||
<BR>
|
||||
If the optional webApp argument is specified then returns the modified assets within that web app.
|
||||
]]>
|
||||
</description>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/sandboxes/{sandboxref}/modified</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/sandboxes/{sandboxref}/modified?webApp={webApp?}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Get the modified items within a sandbox
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
var boxName = urlElements[2];
|
||||
|
||||
var sandbox;
|
||||
|
||||
var webproject = webprojects.getWebProject(shortName);
|
||||
if (webproject == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The webproject, " + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
sandbox = webproject.getSandbox(boxName);
|
||||
if (sandbox == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The sandbox, " + boxName + ", in webproject, " + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var webApp = args["webApp"];
|
||||
|
||||
// set model properties
|
||||
model.sandbox = sandbox;
|
||||
model.webproject = webproject;
|
||||
|
||||
if(webApp != null)
|
||||
{
|
||||
model.assets = sandbox.modifiedAssets(webApp);
|
||||
}
|
||||
else
|
||||
{
|
||||
model.assets = sandbox.modifiedAssets;
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
|
@@ -0,0 +1,11 @@
|
||||
<#import "asset.lib.ftl" as assetLib/>
|
||||
{
|
||||
data: [
|
||||
<#list assets as asset>
|
||||
<@assetLib.assetJSON asset=asset />
|
||||
<#if asset_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,10 @@
|
||||
<webscript>
|
||||
<shortname>Delete Sandbox</shortname>
|
||||
<description>Deletes a WCM sandbox and all its contents.
|
||||
</description>
|
||||
<format default="json" />
|
||||
<url>/api/wcm/webprojects/{webprojectref}/sandboxes/{sandboxRef}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -0,0 +1,43 @@
|
||||
|
||||
/**
|
||||
* Delete a wcm web project sandbox
|
||||
*/
|
||||
|
||||
function main() {
|
||||
|
||||
|
||||
var urlElements = url.extension.split("/");
|
||||
var webprojectref = urlElements[0];
|
||||
var boxName = urlElements[2];
|
||||
|
||||
if (webprojectref == null || webprojectref.length == 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "Delete sandbox. webprojectref missing or blank");
|
||||
return;
|
||||
}
|
||||
|
||||
var webproject = webprojects.getWebProject(webprojectref);
|
||||
|
||||
|
||||
if(webproject != null)
|
||||
{
|
||||
var sandbox = webproject.getSandbox(boxName);
|
||||
if(sandbox != null)
|
||||
{
|
||||
sandbox.deleteSandbox();
|
||||
status.setCode(status.STATUS_OK, "Webproject " + webprojectref + " deleted");
|
||||
}
|
||||
else
|
||||
{
|
||||
status.setCode(status.STATUS_NOT_FOUND, "Unable to delete : Webproject: " + webprojectref + "Sandbox: " + boxName + ", does not exist");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return 404
|
||||
status.setCode(status.STATUS_NOT_FOUND, "Unable to delete : Webproject: " + webprojectref + " does not exist");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
@@ -0,0 +1 @@
|
||||
{}
|
@@ -0,0 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>Get Web Project Sandbox</shortname>
|
||||
<description>Get a single sandbox of a web project.</description>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/sandboxes/{sandboxref}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Get the sandbox for a web project
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
var urlElements = url.extension.split("/");
|
||||
var shortName = urlElements[0];
|
||||
var boxName = urlElements[2];
|
||||
|
||||
var sandbox;
|
||||
|
||||
var webproject = webprojects.getWebProject(shortName);
|
||||
if (webproject == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The webproject, " + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
sandbox = webproject.getSandbox(boxName);
|
||||
if (sandbox == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The sandbox, " + boxName + ", in webproject, " + shortName + ", does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
model.sandbox = sandbox;
|
||||
model.webproject = webproject;
|
||||
}
|
||||
|
||||
main()
|
||||
|
@@ -0,0 +1,6 @@
|
||||
<#import "sandbox.lib.ftl" as sandboxLib/>
|
||||
{
|
||||
data:<@sandboxLib.sandboxJSON webproject=webproject sandbox=sandbox/>
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,17 @@
|
||||
<#macro sandboxJSON webproject sandbox>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"sandboxref" : "${sandbox.sandboxRef}",
|
||||
"name" : "${sandbox.name}",
|
||||
"creator" : "${sandbox.creator}",
|
||||
"createdDate" : { "iso8601" : "${sandbox.createdDateAsISO8601}" },
|
||||
"storeNames" : [
|
||||
<#assign names = sandbox.storeNames />
|
||||
<#list names as name>
|
||||
"${name}" <#if name_has_next>,</#if>
|
||||
</#list>
|
||||
],
|
||||
"url" : "${url.serviceContext + "/api/wcm/webprojects/" + webproject.webProjectRef + "/sandboxes/" + sandbox.sandboxRef}"
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
@@ -0,0 +1,18 @@
|
||||
<webscript>
|
||||
<shortname>Create user sandbox </shortname>
|
||||
<description> <![CDATA[
|
||||
Create (POST) a new author sandbox for a user.
|
||||
<BR>The following fields are required in the body of the request:
|
||||
<UL>
|
||||
<LI>userName</LI>
|
||||
</UL>
|
||||
<BR>
|
||||
Returns STATUS_CREATED on success.
|
||||
]]>
|
||||
</description>
|
||||
<format default="json" />
|
||||
<url>/api/wcm/webprojects/{webprojectref}/sandboxes</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -0,0 +1,6 @@
|
||||
<#import "sandbox.lib.ftl" as sandboxLib/>
|
||||
{
|
||||
data:<@sandboxLib.sandboxJSON webproject=webproject sandbox=sandbox/>
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,40 @@
|
||||
|
||||
/**
|
||||
* Post (create) wcm web project
|
||||
* @return the wcm web project ref
|
||||
*/
|
||||
|
||||
function main() {
|
||||
|
||||
if (!json.has("userName"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "property 'userName' missing when creating sandbox");
|
||||
return;
|
||||
}
|
||||
|
||||
var userName = json.get("userName");
|
||||
|
||||
if (userName.length == 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "property 'userName' blank when creating sandbox");
|
||||
return;
|
||||
}
|
||||
|
||||
var shortName = url.extension.split("/")[0];
|
||||
|
||||
var webproject = webprojects.getWebProject(shortName);
|
||||
if (webproject == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The webproject " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var sandbox = webproject.createSandbox(userName);
|
||||
|
||||
// Set Return value
|
||||
model.webproject = webproject;
|
||||
model.sandbox = sandbox;
|
||||
}
|
||||
|
||||
main()
|
@@ -0,0 +1,10 @@
|
||||
<webscript>
|
||||
<shortname>Web Project Sandboxes</shortname>
|
||||
<description>Get a collection of a web project sandboxes. If userName is specified then returns the sandboxes for the specified user.</description>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/sandboxes?userName={userName?}</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}/sandboxes</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Get the sandboxes for a web project
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
var shortName = url.extension.split("/")[0];
|
||||
|
||||
var sandboxes;
|
||||
|
||||
var webproject = webprojects.getWebProject(shortName);
|
||||
if (webproject == null)
|
||||
{
|
||||
// Site cannot be found
|
||||
status.setCode(status.STATUS_NOT_FOUND, "The webproject " + shortName + " does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var userFilter = args["userName"];
|
||||
|
||||
if(userFilter != null)
|
||||
{
|
||||
sandboxes = webproject.getSandboxes(userFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
sandboxes = webproject.getSandboxes();
|
||||
}
|
||||
model.sandboxes = sandboxes;
|
||||
model.webproject = webproject;
|
||||
}
|
||||
|
||||
main()
|
||||
|
@@ -0,0 +1,13 @@
|
||||
<#import "sandbox.lib.ftl" as sandboxLib/>
|
||||
{
|
||||
data:[
|
||||
<#if sandboxes??>
|
||||
<#assign boxNames = sandboxes?keys />
|
||||
<#list boxNames as boxName>
|
||||
<@sandboxLib.sandboxJSON webproject=webproject sandbox=sandboxes[boxName]/>
|
||||
<#if boxName_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
]
|
||||
}
|
||||
|
@@ -4,7 +4,8 @@
|
||||
webprojectref specifies which project to delete and will have been returned by a prior call to get, create of list web project.
|
||||
</description>
|
||||
<format default="json" />
|
||||
<url>/api/wcm/webproject/{webprojectref}</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -2,7 +2,8 @@
|
||||
<shortname>Get Web Project</shortname>
|
||||
<description>Get a single WCM web project in JSON format.</description>
|
||||
<format default="json" />
|
||||
<url>/api/wcm/webproject/{webprojectref}</url>
|
||||
<url>/api/wcm/webprojects/{webprojectref}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,4 +1,5 @@
|
||||
<#import "webproject.lib.ftl" as webprojectLib/>
|
||||
<@webprojectLib.webprojectJSON webproject=webproject/>
|
||||
|
||||
{
|
||||
data:<@webprojectLib.webprojectJSON webproject=webproject/>
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,23 @@
|
||||
<#macro webprojectJSON webproject>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
|
||||
{
|
||||
"url" : "${url.serviceContext + "/api/wcm/webproject/" + webproject.webProjectRef}",
|
||||
"webprojectref" : "${webproject.webProjectRef}",
|
||||
"name" : "${webproject.name}",
|
||||
"title" : "${webproject.title}",
|
||||
"description" : "${webproject.description}"
|
||||
"url" : <#escape x as jsonUtils.encodeJSONString(x)> "${url.serviceContext + "/api/wcm/webprojects/" + webproject.webProjectRef}", </#escape>
|
||||
"webprojectref" : <#escape x as jsonUtils.encodeJSONString(x)> "${webproject.webProjectRef}", </#escape>
|
||||
"name" : <#escape x as jsonUtils.encodeJSONString(x)> "${webproject.name}", </#escape>
|
||||
"title" : <#escape x as jsonUtils.encodeJSONString(x)> "${webproject.title}", </#escape>
|
||||
"description" : <#escape x as jsonUtils.encodeJSONString(x)> "${webproject.description}", </#escape>
|
||||
"isTemplate" : ${webproject.template?string("true", "false")},
|
||||
"node" : <@nodeJSON nodeRef=webproject.nodeRef/>
|
||||
}
|
||||
|
||||
</#macro>
|
||||
|
||||
// Render a scriptNode for JSON
|
||||
<#macro nodeJSON nodeRef>
|
||||
<#escape y as jsonUtils.encodeJSONString(y)>
|
||||
{
|
||||
"id" : "${nodeRef.id}",
|
||||
"nodeRef" : "${nodeRef}"
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
||||
|
@@ -11,7 +11,8 @@
|
||||
|
||||
</description>
|
||||
<format default="json" />
|
||||
<url>/api/wcm/webproject</url>
|
||||
<url>/api/wcm/webprojects</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,4 +1,5 @@
|
||||
<#import "webproject.lib.ftl" as webprojectLib/>
|
||||
<@webprojectLib.webprojectJSON webproject=webproject/>
|
||||
|
||||
{
|
||||
data:<@webprojectLib.webprojectJSON webproject=webproject/>
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,21 @@
|
||||
<webscript>
|
||||
<shortname>Update Web Project</shortname>
|
||||
<description>Update a single WCM web project
|
||||
<description>
|
||||
<![CDATA[
|
||||
Update a single WCM web project
|
||||
<BR>
|
||||
The following fields are may be updated in the body of the request:
|
||||
name, title, description
|
||||
<ul>
|
||||
<li>name</li>
|
||||
<li>title</li>
|
||||
<li>description</li>
|
||||
<li>isTemplate</li>
|
||||
<ul>
|
||||
]]>
|
||||
</description>
|
||||
<url>/api/wcm/webprojects/{webprojectref}</url>
|
||||
<format default="json" />
|
||||
<url>/api/wcm/webproject/{webprojectref}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,4 +1,5 @@
|
||||
<#import "webproject.lib.ftl" as webprojectLib/>
|
||||
<@webprojectLib.webprojectJSON webproject=webproject/>
|
||||
|
||||
{
|
||||
data:<@webprojectLib.webprojectJSON webproject=webproject/>
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,11 @@ function main() {
|
||||
var description = json.get("description");
|
||||
webproject.setDescription(description);
|
||||
}
|
||||
if(json.has("isTemplate"))
|
||||
{
|
||||
var isTemplate = json.get("isTemplate");
|
||||
webproject.setDescription(isTemplate);
|
||||
}
|
||||
|
||||
// update the web project
|
||||
webproject.save();
|
||||
|
@@ -1,9 +1,13 @@
|
||||
<webscript>
|
||||
<shortname>Web Projects</shortname>
|
||||
<description>Get a list of the WCM Web projects, if userName is specified then only those web projects for the
|
||||
specified user are returned else all web projects are returned.</description>
|
||||
<description>Get a list of the WCM Web projects. userName is an optional argument that if
|
||||
specified then only those web projects for the
|
||||
specified user are returned else all web projects are returned.
|
||||
</description>
|
||||
<format default="json" />
|
||||
<url>/api/wcm/webprojects?userName={userName?}</url>
|
||||
<url>/api/wcm/webprojects</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<family>WCM Service</family>
|
||||
</webscript>
|
@@ -1,8 +1,10 @@
|
||||
<#import "webproject.lib.ftl" as webprojectLib/>
|
||||
|
||||
[
|
||||
{
|
||||
data:[
|
||||
<#list webprojects as webproject>
|
||||
<@webprojectLib.webprojectJSON webproject=webproject/>
|
||||
<#if webproject_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
|
@@ -241,6 +241,15 @@
|
||||
<property name="mimetypeService" ref="MimetypeService" />
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- AVM Remote Store -->
|
||||
<!-- bean id="AVMStoreBean" class="org.alfresco.repo.web.scripts.bean.AVMRemoteStore">
|
||||
<property name="mimetypeService" ref="MimetypeService" />
|
||||
<property name="avmService" ref="AVMService" />
|
||||
<property name="searchService" ref="SearchService" />
|
||||
</bean>
|
||||
-->
|
||||
|
||||
<!-- Remote Store service - AVM -->
|
||||
<bean id="webscript.org.alfresco.repository.store.remoteavm.get" class="org.alfresco.repo.web.scripts.bean.AVMRemoteStore" parent="webscript">
|
||||
<property name="mimetypeService" ref="MimetypeService" />
|
||||
|
@@ -57,7 +57,6 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
private static final String USER_TWO = "WebProjectTestTwo";
|
||||
private static final String USER_THREE = "WebProjectTestThree";
|
||||
|
||||
private static final String URL_WEB_PROJECT = "/api/wcm/webproject";
|
||||
private static final String URL_WEB_PROJECTS = "/api/wcm/webprojects";
|
||||
|
||||
private static final String BASIC_NAME = "testProj";
|
||||
@@ -118,7 +117,7 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
try
|
||||
{
|
||||
Response deleteResponse = sendRequest(new DeleteRequest(URL_WEB_PROJECT + "/" + webProjectRef), 0);
|
||||
sendRequest(new DeleteRequest(URL_WEB_PROJECTS + "/" + webProjectRef), 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -134,6 +133,8 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
this.authenticationComponent.setCurrentUser("admin");
|
||||
|
||||
sendRequest(new DeleteRequest(URL_WEB_PROJECTS + "/" + BASIC_DNSNAME),0 );
|
||||
|
||||
/**
|
||||
* Create a web site
|
||||
*/
|
||||
@@ -142,9 +143,12 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
webProj.put("description", BASIC_DESCRIPTION);
|
||||
webProj.put("title", BASIC_TITLE);
|
||||
webProj.put("dnsName", BASIC_DNSNAME);
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECT, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
webProj.put("isTemplate", true);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECTS, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
JSONObject top = new JSONObject(response.getContentAsString());
|
||||
JSONObject result = top.getJSONObject("data");
|
||||
String webProjectRef = result.getString("webprojectref");
|
||||
|
||||
assertNotNull("webproject ref is null", webProjectRef);
|
||||
@@ -153,16 +157,22 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
assertEquals(BASIC_NAME, result.get("name"));
|
||||
assertEquals(BASIC_DESCRIPTION, result.get("description"));
|
||||
assertEquals(BASIC_TITLE, result.get("title"));
|
||||
// not yet implemented
|
||||
//assertEquals(true, result.get("isTemplate"));
|
||||
|
||||
/**
|
||||
* Read the web site we created above
|
||||
*/
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECT + "/" + webProjectRef), 200);
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECTS + "/" + webProjectRef), Status.STATUS_OK);
|
||||
{
|
||||
JSONObject lookupResult = new JSONObject(lookup.getContentAsString());
|
||||
assertEquals(BASIC_NAME, lookupResult.get("name"));
|
||||
assertEquals(BASIC_DESCRIPTION, lookupResult.get("description"));
|
||||
assertEquals(BASIC_TITLE, lookupResult.get("title"));
|
||||
JSONObject data = lookupResult.getJSONObject("data");
|
||||
assertEquals(BASIC_NAME, data.get("name"));
|
||||
assertEquals(BASIC_DESCRIPTION, data.get("description"));
|
||||
assertEquals(BASIC_TITLE, data.get("title"));
|
||||
String url = data.getString("url");
|
||||
assertNotNull("url is null", url);
|
||||
sendRequest(new GetRequest(url), Status.STATUS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,19 +181,19 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
JSONObject update = new JSONObject();
|
||||
update.put("name", BASIC_UPDATED_NAME);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECT + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECTS + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject updateResult = new JSONObject(updateResponse.getContentAsString());
|
||||
|
||||
// TODO TESTS NOT PASSING
|
||||
// assertEquals(BASIC_UPDATED_NAME, updateResult.get("name"));
|
||||
// assertEquals(BASIC_DESCRIPTION, updateResult.get("description"));
|
||||
// assertEquals(BASIC_TITLE, updateResult.get("title"));
|
||||
// JSONObject data = updateResult.getJSONObject("data");
|
||||
// assertEquals(BASIC_UPDATED_NAME, data.get("name"));
|
||||
// assertEquals(BASIC_DESCRIPTION, data.get("description"));
|
||||
// assertEquals(BASIC_TITLE, data.get("title"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the web site we created above
|
||||
*/
|
||||
Response deleteResponse = sendRequest(new DeleteRequest(URL_WEB_PROJECT + "/" + webProjectRef), Status.STATUS_OK);
|
||||
sendRequest(new DeleteRequest(URL_WEB_PROJECTS + "/" + webProjectRef), Status.STATUS_OK);
|
||||
} // END testBasicCRUDWebProject
|
||||
|
||||
public void testListWebSites() throws Exception
|
||||
@@ -202,10 +212,11 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
webProj.put("description", BASIC_DESCRIPTION + i);
|
||||
webProj.put("title", BASIC_TITLE + i);
|
||||
webProj.put("dnsName", BASIC_DNSNAME + i);
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECT, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECTS, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
String webProjectRef = result.getString("webprojectref");
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String webProjectRef = data.getString("webprojectref");
|
||||
this.createdWebProjects.add(webProjectRef);
|
||||
}
|
||||
|
||||
@@ -215,17 +226,18 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
Response list = sendRequest(new GetRequest(URL_WEB_PROJECTS), Status.STATUS_OK);
|
||||
|
||||
JSONArray lookupResult = new JSONArray(list.getContentAsString());
|
||||
assertTrue(lookupResult.length() >= LOOP_COUNT);
|
||||
JSONObject lookupResult = new JSONObject(list.getContentAsString());
|
||||
JSONArray data = lookupResult.getJSONArray("data");
|
||||
assertTrue(data.length() >= LOOP_COUNT);
|
||||
|
||||
/**
|
||||
* Now check that the list contains the sites created above
|
||||
*/
|
||||
int foundCount = 0;
|
||||
|
||||
for(int i = 0; i < lookupResult.length(); i++)
|
||||
for(int i = 0; i < data.length(); i++)
|
||||
{
|
||||
JSONObject obj = lookupResult.getJSONObject(i);
|
||||
JSONObject obj = data.getJSONObject(i);
|
||||
String name = obj.getString("name");
|
||||
if(name.contains(BASIC_NAME))
|
||||
{
|
||||
@@ -240,14 +252,11 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
*/
|
||||
{
|
||||
String stepURL = "/api/wcm/webprojects?userName=Freddy";
|
||||
Response list = sendRequest(new GetRequest(stepURL), Status.STATUS_OK);
|
||||
JSONArray lookupResult = new JSONArray(list.getContentAsString());
|
||||
assertTrue(lookupResult.length() == 0);
|
||||
Response listResponse = sendRequest(new GetRequest(stepURL), Status.STATUS_OK);
|
||||
JSONObject lookupResult = new JSONObject(listResponse.getContentAsString());
|
||||
JSONArray data = lookupResult.getJSONArray("data");
|
||||
assertTrue(data.length() == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // testListWebSites
|
||||
|
||||
public void testUpdateWebProject() throws Exception
|
||||
@@ -262,11 +271,12 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
webProj.put("description", BASIC_DESCRIPTION);
|
||||
webProj.put("title", BASIC_TITLE);
|
||||
webProj.put("dnsName", BASIC_DNSNAME);
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECT, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECTS, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject top = new JSONObject(response.getContentAsString());
|
||||
JSONObject result = top.getJSONObject("data");
|
||||
String webProjectRef = result.getString("webprojectref");
|
||||
|
||||
|
||||
assertNotNull("webproject ref is null", webProjectRef);
|
||||
this.createdWebProjects.add(webProjectRef);
|
||||
|
||||
@@ -274,11 +284,12 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
* Read the web site we created above to double check it created correctly
|
||||
*/
|
||||
{
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECT + "/" + webProjectRef), Status.STATUS_OK);
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECTS + "/" + webProjectRef), Status.STATUS_OK);
|
||||
JSONObject lookupResult = new JSONObject(lookup.getContentAsString());
|
||||
assertEquals(BASIC_NAME, lookupResult.get("name"));
|
||||
assertEquals(BASIC_DESCRIPTION, lookupResult.get("description"));
|
||||
assertEquals(BASIC_TITLE, lookupResult.get("title"));
|
||||
JSONObject data = lookupResult.getJSONObject("data");
|
||||
assertEquals(BASIC_NAME, data.get("name"));
|
||||
assertEquals(BASIC_DESCRIPTION, data.get("description"));
|
||||
assertEquals(BASIC_TITLE, data.get("title"));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -287,17 +298,18 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
JSONObject update = new JSONObject();
|
||||
update.put("description", BASIC_UPDATED_DESCRIPTION);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECT + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECTS + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject updateResult = new JSONObject(updateResponse.getContentAsString());
|
||||
|
||||
/*
|
||||
* Read the result, check description updated and other properties remain unchanged
|
||||
*/
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECT + "/" + webProjectRef), Status.STATUS_OK);
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECTS + "/" + webProjectRef), Status.STATUS_OK);
|
||||
JSONObject lookupResult = new JSONObject(lookup.getContentAsString());
|
||||
assertEquals(BASIC_NAME, lookupResult.get("name"));
|
||||
assertEquals(BASIC_UPDATED_DESCRIPTION, lookupResult.get("description"));
|
||||
assertEquals(BASIC_TITLE, lookupResult.get("title"));
|
||||
JSONObject data = lookupResult.getJSONObject("data");
|
||||
assertEquals(BASIC_NAME, data.get("name"));
|
||||
assertEquals(BASIC_UPDATED_DESCRIPTION, data.get("description"));
|
||||
assertEquals(BASIC_TITLE, data.get("title"));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -306,17 +318,18 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
JSONObject update = new JSONObject();
|
||||
update.put("title", BASIC_UPDATED_TITLE);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECT + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject updateResult = new JSONObject(updateResponse.getContentAsString());
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECTS + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
new JSONObject(updateResponse.getContentAsString());
|
||||
|
||||
/*
|
||||
* Read the result, check description updated and other properties unchanged
|
||||
*/
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECT + "/" + webProjectRef), Status.STATUS_OK);
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECTS + "/" + webProjectRef), Status.STATUS_OK);
|
||||
JSONObject lookupResult = new JSONObject(lookup.getContentAsString());
|
||||
assertEquals(BASIC_NAME, lookupResult.get("name"));
|
||||
assertEquals(BASIC_UPDATED_DESCRIPTION, lookupResult.get("description"));
|
||||
assertEquals(BASIC_UPDATED_TITLE, lookupResult.get("title"));
|
||||
JSONObject data = lookupResult.getJSONObject("data");
|
||||
assertEquals(BASIC_NAME, data.get("name"));
|
||||
assertEquals(BASIC_UPDATED_DESCRIPTION, data.get("description"));
|
||||
assertEquals(BASIC_UPDATED_TITLE, data.get("title"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,17 +338,18 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
JSONObject update = new JSONObject();
|
||||
update.put("name", BASIC_UPDATED_NAME);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECT + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECTS + "/" + webProjectRef, update.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject updateResult = new JSONObject(updateResponse.getContentAsString());
|
||||
|
||||
/*
|
||||
* Read the result, check description updated and other properties unchanged
|
||||
*/
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECT + "/" + webProjectRef), Status.STATUS_OK);
|
||||
Response lookup = sendRequest(new GetRequest(URL_WEB_PROJECTS + "/" + webProjectRef), Status.STATUS_OK);
|
||||
JSONObject lookupResult = new JSONObject(lookup.getContentAsString());
|
||||
assertEquals(BASIC_UPDATED_NAME, lookupResult.get("name"));
|
||||
assertEquals(BASIC_UPDATED_DESCRIPTION, lookupResult.get("description"));
|
||||
assertEquals(BASIC_UPDATED_TITLE, lookupResult.get("title"));
|
||||
JSONObject data = lookupResult.getJSONObject("data");
|
||||
assertEquals(BASIC_UPDATED_NAME, data.get("name"));
|
||||
assertEquals(BASIC_UPDATED_DESCRIPTION, data.get("description"));
|
||||
assertEquals(BASIC_UPDATED_TITLE, data.get("title"));
|
||||
|
||||
}
|
||||
|
||||
@@ -347,8 +361,7 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
{
|
||||
JSONObject update = new JSONObject();
|
||||
update.put("name", BASIC_UPDATED_NAME);
|
||||
Response updateResponse = sendRequest(new PutRequest(URL_WEB_PROJECT + "/" + BAD_PROJECT_REF, update.toString(), "application/json"), Status.STATUS_NOT_FOUND);
|
||||
JSONObject updateResult = new JSONObject(updateResponse.getContentAsString());
|
||||
sendRequest(new PutRequest(URL_WEB_PROJECTS + "/" + BAD_PROJECT_REF, update.toString(), "application/json"), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
} // end testUpdateWebProject
|
||||
@@ -361,7 +374,7 @@ public class WebProjectTest extends BaseWebScriptTest
|
||||
* Delete a project that does not exist
|
||||
*/
|
||||
{
|
||||
Response deleteResponse = sendRequest(new DeleteRequest(URL_WEB_PROJECT + "/" + BAD_PROJECT_REF), Status.STATUS_NOT_FOUND);
|
||||
sendRequest(new DeleteRequest(URL_WEB_PROJECTS + "/" + BAD_PROJECT_REF), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
} // end testDeleteWebproject
|
||||
|
@@ -64,7 +64,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
public static final String ROLE_CONTENT_REVIEWER = "ContentReviewer";
|
||||
public static final String ROLE_CONTENT_CONTRIBUTOR = "ContentContributor";
|
||||
|
||||
private static final String URL_WEB_PROJECT = "/api/wcm/webproject";
|
||||
private static final String URL_WEB_PROJECTS = "/api/wcm/webprojects";
|
||||
private static final String URL_MEMBERSHIPS = "/memberships";
|
||||
private static final String BASIC_NAME = "testProj";
|
||||
private static final String BASIC_DESCRIPTION = "testDescription";
|
||||
@@ -121,7 +121,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
{
|
||||
try
|
||||
{
|
||||
sendRequest(new DeleteRequest(URL_WEB_PROJECT + "/" + webProjectRef), 0);
|
||||
sendRequest(new DeleteRequest(URL_WEB_PROJECTS + "/" + webProjectRef), 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -148,10 +148,11 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
webProj.put("description", BASIC_DESCRIPTION);
|
||||
webProj.put("title", BASIC_TITLE);
|
||||
webProj.put("dnsName", BASIC_DNSNAME);
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECT, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECTS, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
String webProjectRef = result.getString("webprojectref");
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String webProjectRef = data.getString("webprojectref");
|
||||
|
||||
assertNotNull("webproject ref is null", webProjectRef);
|
||||
this.createdWebProjects.add(webProjectRef);
|
||||
@@ -166,17 +167,18 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
// Create a site
|
||||
String webProjectRef = createWebProject();
|
||||
|
||||
String validURL = URL_WEB_PROJECT + "/" + webProjectRef + "/memberships";
|
||||
String validURL = URL_WEB_PROJECTS + "/" + webProjectRef + "/memberships";
|
||||
|
||||
/**
|
||||
* A newly created web project has 1 users (admin is a special case)
|
||||
*/
|
||||
{
|
||||
Response response = sendRequest(new GetRequest(validURL), Status.STATUS_OK);
|
||||
JSONArray result = new JSONArray(response.getContentAsString());
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONArray data = result.getJSONArray("data");
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.length());
|
||||
assertNotNull(data);
|
||||
assertEquals(1, data.length());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,14 +193,15 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
sendRequest(new PostRequest(validURL, membership.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
Response response = sendRequest(new GetRequest(validURL), Status.STATUS_OK);
|
||||
JSONArray result = new JSONArray(response.getContentAsString());
|
||||
assertNotNull(result);
|
||||
assertEquals(2, result.length());
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONArray data = result.getJSONArray("data");
|
||||
assertNotNull(data);
|
||||
assertEquals(2, data.length());
|
||||
|
||||
boolean foundUser = false;
|
||||
for(int i = 0; i < result.length(); i++)
|
||||
for(int i = 0; i < data.length(); i++)
|
||||
{
|
||||
JSONObject obj = result.getJSONObject(i);
|
||||
JSONObject obj = data.getJSONObject(i);
|
||||
if(USER_ONE.equals(obj.getJSONObject("person").get("userName")))
|
||||
{
|
||||
assertEquals(ROLE_CONTENT_MANAGER, obj.get("role"));
|
||||
@@ -222,14 +225,15 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
sendRequest(new PostRequest(validURL, membership.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
Response response = sendRequest(new GetRequest(validURL), Status.STATUS_OK);
|
||||
JSONArray result = new JSONArray(response.getContentAsString());
|
||||
assertNotNull(result);
|
||||
assertEquals(3, result.length());
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONArray data = result.getJSONArray("data");
|
||||
assertNotNull(data);
|
||||
assertEquals(3, data.length());
|
||||
|
||||
boolean foundUser = false;
|
||||
for(int i = 0; i < result.length(); i++)
|
||||
for(int i = 0; i < data.length(); i++)
|
||||
{
|
||||
JSONObject obj = result.getJSONObject(i);
|
||||
JSONObject obj = data.getJSONObject(i);
|
||||
if(USER_TWO.equals(obj.getJSONObject("person").get("userName")))
|
||||
{
|
||||
assertEquals(ROLE_CONTENT_REVIEWER, obj.get("role"));
|
||||
@@ -247,8 +251,9 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
{
|
||||
String stepURL = "/api/wcm/webprojects?userName=" + USER_TWO;
|
||||
Response list = sendRequest(new GetRequest(stepURL), Status.STATUS_OK);
|
||||
JSONArray lookupResult = new JSONArray(list.getContentAsString());
|
||||
assertTrue(lookupResult.length() == 1);
|
||||
JSONObject response = new JSONObject(list.getContentAsString());
|
||||
JSONArray data = response.getJSONArray("data");
|
||||
assertTrue(data.length() == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +261,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
* Project not found
|
||||
*/
|
||||
{
|
||||
String invalidURL = URL_WEB_PROJECT + "/" + "NotExist" + "/memberships";
|
||||
String invalidURL = URL_WEB_PROJECTS + "/" + "NotExist" + "/memberships";
|
||||
sendRequest(new GetRequest(invalidURL), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -268,7 +273,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
|
||||
String webProjectRef = createWebProject();
|
||||
|
||||
String validURL = URL_WEB_PROJECT + "/" + webProjectRef + "/memberships";
|
||||
String validURL = URL_WEB_PROJECTS + "/" + webProjectRef + "/memberships";
|
||||
|
||||
/**
|
||||
* Create a new membership
|
||||
@@ -282,23 +287,25 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
|
||||
Response response = sendRequest(new PostRequest(validURL, membership.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
|
||||
// Check the result
|
||||
assertEquals(ROLE_CONTENT_MANAGER, result.get("role"));
|
||||
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
|
||||
assertEquals(ROLE_CONTENT_MANAGER, data.get("role"));
|
||||
assertEquals(USER_TWO, data.getJSONObject("person").get("userName"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the membership
|
||||
*/
|
||||
{
|
||||
String validGetURL = URL_WEB_PROJECT + "/" + webProjectRef + "/membership/" + USER_TWO;
|
||||
String validGetURL = URL_WEB_PROJECTS + "/" + webProjectRef + "/memberships/" + USER_TWO;
|
||||
Response response = sendRequest(new GetRequest(validGetURL), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
|
||||
// Check the result
|
||||
assertEquals(ROLE_CONTENT_MANAGER, result.get("role"));
|
||||
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
|
||||
assertEquals(ROLE_CONTENT_MANAGER, data.get("role"));
|
||||
assertEquals(USER_TWO, data.getJSONObject("person").get("userName"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,10 +321,11 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
|
||||
Response response = sendRequest(new PostRequest(validURL, membership.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
|
||||
// Check the result
|
||||
assertEquals(ROLE_CONTENT_MANAGER, result.get("role"));
|
||||
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
|
||||
assertEquals(ROLE_CONTENT_MANAGER, data.get("role"));
|
||||
assertEquals(USER_TWO, data.getJSONObject("person").get("userName"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,8 +363,8 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
String webProjectRef = createWebProject();
|
||||
|
||||
// Test error conditions
|
||||
sendRequest(new GetRequest(URL_WEB_PROJECT + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE), Status.STATUS_NOT_FOUND);
|
||||
String validURL = URL_WEB_PROJECT + "/" + webProjectRef + "/membership/";
|
||||
sendRequest(new GetRequest(URL_WEB_PROJECTS + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE), Status.STATUS_NOT_FOUND);
|
||||
String validURL = URL_WEB_PROJECTS + "/" + webProjectRef + URL_MEMBERSHIPS ;
|
||||
|
||||
// User not found
|
||||
sendRequest(new GetRequest(validURL + "baduser"), Status.STATUS_NOT_FOUND);
|
||||
@@ -364,12 +372,13 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
/**
|
||||
* Now lookup the admin user and check they are a content manager
|
||||
*/
|
||||
Response response = sendRequest(new GetRequest(validURL + USER_ADMIN), Status.STATUS_OK);
|
||||
Response response = sendRequest(new GetRequest(validURL + "/" + USER_ADMIN), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
|
||||
// Check the result
|
||||
assertEquals(ROLE_CONTENT_MANAGER, result.get("role"));
|
||||
assertEquals(USER_ADMIN, result.getJSONObject("person").get("userName"));
|
||||
assertEquals(ROLE_CONTENT_MANAGER, data.get("role"));
|
||||
assertEquals(USER_ADMIN, data.getJSONObject("person").get("userName"));
|
||||
}
|
||||
|
||||
// Update Not yet implemented
|
||||
@@ -464,7 +473,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
|
||||
String webProjectRef = createWebProject();
|
||||
|
||||
String validURL = URL_WEB_PROJECT + "/" + webProjectRef + "/memberships";
|
||||
String validURL = URL_WEB_PROJECTS + "/" + webProjectRef + "/memberships";
|
||||
|
||||
/**
|
||||
* Create a new membership
|
||||
@@ -478,13 +487,14 @@ public class WebProjectMembershipTest extends BaseWebScriptTest
|
||||
|
||||
Response response = sendRequest(new PostRequest(validURL, membership.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
|
||||
// Check the result
|
||||
assertEquals(ROLE_CONTENT_MANAGER, result.get("role"));
|
||||
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
|
||||
assertEquals(ROLE_CONTENT_MANAGER, data.get("role"));
|
||||
assertEquals(USER_TWO, data.getJSONObject("person").get("userName"));
|
||||
}
|
||||
|
||||
String validGetURL = URL_WEB_PROJECT + "/" + webProjectRef + "/membership/" + USER_TWO;
|
||||
String validGetURL = URL_WEB_PROJECTS + "/" + webProjectRef + URL_MEMBERSHIPS + "/" + USER_TWO;
|
||||
|
||||
{
|
||||
sendRequest(new GetRequest(validGetURL), Status.STATUS_OK);
|
||||
|
@@ -0,0 +1,480 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.web.scripts.wcm.sandbox;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.util.ISO8601DateFormat;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.alfresco.web.scripts.Status;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.Response;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Junit tests of the REST bindings for WCM Sandbox and WCM Sandboxes
|
||||
* @author mrogers
|
||||
*
|
||||
*/
|
||||
public class SandboxTest extends BaseWebScriptTest {
|
||||
|
||||
private AuthenticationService authenticationService;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private PersonService personService;
|
||||
|
||||
private static final String USER_ONE = "WebProjectTestOne";
|
||||
private static final String USER_TWO = "WebProjectTestTwo";
|
||||
private static final String USER_THREE = "WebProjectTestThree";
|
||||
private static final String USER_FOUR = "WebProjectTestFour";
|
||||
private static final String USER_ADMIN = "admin";
|
||||
public static final String ROLE_CONTENT_MANAGER = "ContentManager";
|
||||
public static final String ROLE_CONTENT_PUBLISHER = "ContentPublisher";
|
||||
public static final String ROLE_CONTENT_REVIEWER = "ContentReviewer";
|
||||
public static final String ROLE_CONTENT_CONTRIBUTOR = "ContentContributor";
|
||||
|
||||
private static final String URL_WEB_PROJECT = "/api/wcm/webprojects";
|
||||
private static final String URI_MEMBERSHIPS = "/memberships";
|
||||
private static final String URI_SANDBOXES = "/sandboxes";
|
||||
private static final String BASIC_NAME = "testProj";
|
||||
private static final String BASIC_DESCRIPTION = "testDescription";
|
||||
private static final String BASIC_TITLE = "testTitle";
|
||||
private static final String BASIC_DNSNAME = "testDNSName";
|
||||
|
||||
private List<String> createdWebProjects = new ArrayList<String>(5);
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
this.authenticationService = (AuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService");
|
||||
this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent");
|
||||
this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
|
||||
|
||||
// Create users
|
||||
createUser(USER_ONE);
|
||||
createUser(USER_TWO);
|
||||
createUser(USER_THREE);
|
||||
createUser(USER_FOUR);
|
||||
|
||||
// Do tests as user one
|
||||
this.authenticationComponent.setCurrentUser(USER_ONE);
|
||||
}
|
||||
|
||||
private void createUser(String userName)
|
||||
{
|
||||
if (this.authenticationService.authenticationExists(userName) == false)
|
||||
{
|
||||
this.authenticationService.createAuthentication(userName, "PWD".toCharArray());
|
||||
|
||||
PropertyMap ppOne = new PropertyMap(4);
|
||||
ppOne.put(ContentModel.PROP_USERNAME, userName);
|
||||
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
|
||||
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
|
||||
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
|
||||
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
||||
|
||||
this.personService.createPerson(ppOne);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new membership
|
||||
*/
|
||||
private void createMembership(String webProjectRef, String userName, String role) throws Exception
|
||||
{
|
||||
String validURL = URL_WEB_PROJECT + "/" + webProjectRef + "/memberships";
|
||||
JSONObject membership = new JSONObject();
|
||||
membership.put("role", ROLE_CONTENT_MANAGER);
|
||||
JSONObject person = new JSONObject();
|
||||
person.put("userName", USER_TWO);
|
||||
membership.put("person", person);
|
||||
|
||||
sendRequest(new PostRequest(validURL, membership.toString(), "application/json"), Status.STATUS_OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
this.authenticationComponent.setCurrentUser("admin");
|
||||
|
||||
// Tidy-up any web projects created during the execution of the test
|
||||
for (String webProjectRef : this.createdWebProjects)
|
||||
{
|
||||
try
|
||||
{
|
||||
sendRequest(new DeleteRequest(URL_WEB_PROJECT + "/" + webProjectRef), 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// ignore exception here
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the list
|
||||
this.createdWebProjects.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* create a web project
|
||||
* @return the webprojectref
|
||||
* @throws Exception
|
||||
*/
|
||||
private String createWebProject() throws Exception
|
||||
{
|
||||
/**
|
||||
* Create a web site
|
||||
*/
|
||||
JSONObject webProj = new JSONObject();
|
||||
webProj.put("name", BASIC_NAME);
|
||||
webProj.put("description", BASIC_DESCRIPTION);
|
||||
webProj.put("title", BASIC_TITLE);
|
||||
webProj.put("dnsName", BASIC_DNSNAME);
|
||||
Response response = sendRequest(new PostRequest(URL_WEB_PROJECT, webProj.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String webProjectRef = data.getString("webprojectref");
|
||||
|
||||
assertNotNull("webproject ref is null", webProjectRef);
|
||||
this.createdWebProjects.add(webProjectRef);
|
||||
return webProjectRef;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CRUD Sandbox
|
||||
* Create a sandbox, get it, and delete it
|
||||
* Is update supported? - There are no read-write attributes yet.
|
||||
*/
|
||||
public void testCreateSandbox() throws Exception
|
||||
{
|
||||
this.authenticationComponent.setCurrentUser("admin");
|
||||
|
||||
String webprojref = createWebProject();
|
||||
|
||||
createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER);
|
||||
|
||||
String sandboxref ;
|
||||
|
||||
/**
|
||||
* Create a sandbox
|
||||
*/
|
||||
{
|
||||
JSONObject box = new JSONObject();
|
||||
box.put("userName", USER_ONE);
|
||||
String validURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes";
|
||||
Response response = sendRequest(new PostRequest(validURL, box.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
|
||||
sandboxref = data.getString("sandboxref");
|
||||
String url = data.getString("url");
|
||||
String name = data.getString("name");
|
||||
JSONObject createdDate = data.getJSONObject("createdDate");
|
||||
String createdOn = createdDate.getString("iso8601");
|
||||
String createdBy = data.getString("creator");
|
||||
assertNotNull("created date is null", createdOn );
|
||||
assertNotNull("created by is null", createdBy );
|
||||
assertNotNull("sandboxref is null", sandboxref);
|
||||
assertNotNull("url is null", url);
|
||||
assertNotNull("name is null", name);
|
||||
|
||||
// check created date - throws exception if format invalid
|
||||
@SuppressWarnings("unused")
|
||||
java.util.Date d = ISO8601DateFormat.parse(createdOn);
|
||||
|
||||
// lookup url returned
|
||||
sendRequest(new GetRequest(url), Status.STATUS_OK);
|
||||
}
|
||||
String sandboxURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes/" + sandboxref;
|
||||
|
||||
/**
|
||||
* Get the sandbox
|
||||
*/
|
||||
sendRequest(new GetRequest(sandboxURL), Status.STATUS_OK);
|
||||
|
||||
|
||||
/**
|
||||
* Delete the sandbox
|
||||
*/
|
||||
sendRequest(new DeleteRequest(sandboxURL), Status.STATUS_OK);
|
||||
|
||||
/**
|
||||
* Create a sandbox - negative test - no userName
|
||||
*/
|
||||
{
|
||||
JSONObject box = new JSONObject();
|
||||
String validURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes";
|
||||
sendRequest(new PostRequest(validURL, box.toString(), "application/json"), Status.STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the list sandbox method
|
||||
*/
|
||||
public void testListSandbox() throws Exception
|
||||
{
|
||||
this.authenticationComponent.setCurrentUser("admin");
|
||||
String webprojref = createWebProject();
|
||||
|
||||
/**
|
||||
* Call the list sandboxes method
|
||||
*/
|
||||
{
|
||||
String sandboxesURL = URL_WEB_PROJECT + "/" + webprojref + URI_SANDBOXES;
|
||||
Response list = sendRequest(new GetRequest(sandboxesURL), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(list.getContentAsString());
|
||||
JSONArray lookupResult = result.getJSONArray("data");
|
||||
|
||||
// By default there should be a staging sandbox
|
||||
assertTrue("list of sandboxes is empty", lookupResult.length() > 0);
|
||||
}
|
||||
|
||||
createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER);
|
||||
createMembership(webprojref, USER_TWO, ROLE_CONTENT_REVIEWER);
|
||||
createMembership(webprojref, USER_THREE, ROLE_CONTENT_CONTRIBUTOR);
|
||||
String validURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes";
|
||||
JSONObject box = new JSONObject();
|
||||
box.put("userName", USER_ONE);
|
||||
sendRequest(new PostRequest(validURL, box.toString(), "application/json"), Status.STATUS_OK);
|
||||
box.put("userName", USER_TWO);
|
||||
sendRequest(new PostRequest(validURL, box.toString(), "application/json"), Status.STATUS_OK);
|
||||
box.put("userName", USER_THREE);
|
||||
sendRequest(new PostRequest(validURL, box.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
/**
|
||||
* List the sandboxes belonging to USER_ONE
|
||||
*/
|
||||
{
|
||||
String sandboxesURL = URL_WEB_PROJECT + "/" + webprojref + URI_SANDBOXES + "?userName=" + USER_ONE;
|
||||
Response list = sendRequest(new GetRequest(sandboxesURL), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(list.getContentAsString());
|
||||
JSONArray lookupResult = result.getJSONArray("data");
|
||||
|
||||
assertTrue("testListUserSandbox", lookupResult.length() == 1);
|
||||
JSONObject obj1 = lookupResult.getJSONObject(0);
|
||||
String url = obj1.getString("url");
|
||||
String name = obj1.getString("name");
|
||||
assertNotNull("url is null", url);
|
||||
assertNotNull("name is null", name);
|
||||
|
||||
/**
|
||||
* Should be able to lookup the url returned
|
||||
*/
|
||||
sendRequest(new GetRequest(url), Status.STATUS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the sandboxes belonging to USER_TWO
|
||||
*/
|
||||
{
|
||||
String sandboxesURL = URL_WEB_PROJECT + "/" + webprojref + URI_SANDBOXES + "?userName=" + USER_TWO;
|
||||
Response list = sendRequest(new GetRequest(sandboxesURL), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(list.getContentAsString());
|
||||
JSONArray lookupResult = result.getJSONArray("data");
|
||||
|
||||
assertTrue("testListUserSandbox", lookupResult.length() == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the list sandboxes method
|
||||
*/
|
||||
{
|
||||
String sandboxesURL = URL_WEB_PROJECT + "/" + webprojref + URI_SANDBOXES;
|
||||
Response list = sendRequest(new GetRequest(sandboxesURL), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(list.getContentAsString());
|
||||
JSONArray lookupResult = result.getJSONArray("data");
|
||||
|
||||
// There have been 3 creates above
|
||||
assertTrue("list of sandboxes is empty", lookupResult.length() > 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test
|
||||
* Call the list sandbox method for a web project that does not exist
|
||||
*/
|
||||
{
|
||||
String sandboxesURL = URL_WEB_PROJECT + "/" + "twaddle" + URI_SANDBOXES;
|
||||
sendRequest(new GetRequest(sandboxesURL), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test
|
||||
* Call the list sandbox method for a user that does not have a sandbox project that does not exist
|
||||
*/
|
||||
{
|
||||
String sandboxesURL = URL_WEB_PROJECT + "/" + webprojref + URI_SANDBOXES + "?userName=" + USER_FOUR;
|
||||
Response list = sendRequest(new GetRequest(sandboxesURL), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(list.getContentAsString());
|
||||
JSONArray lookupResult = result.getJSONArray("data");
|
||||
assertTrue("lookup user 4 (not existing) found a sandbox", lookupResult.length() == 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the get sandbox method
|
||||
*/
|
||||
public void testGetSandbox() throws Exception
|
||||
{
|
||||
this.authenticationComponent.setCurrentUser("admin");
|
||||
|
||||
String webprojref = createWebProject();
|
||||
|
||||
createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER);
|
||||
|
||||
String sandboxref ;
|
||||
|
||||
/**
|
||||
* Create a sandbox
|
||||
*/
|
||||
{
|
||||
JSONObject box = new JSONObject();
|
||||
box.put("userName", USER_ONE);
|
||||
String validURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes";
|
||||
Response response = sendRequest(new PostRequest(validURL, box.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
sandboxref = data.getString("sandboxref");
|
||||
assertNotNull("sandboxref is null", sandboxref);
|
||||
|
||||
}
|
||||
String sandboxURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes/" + sandboxref;
|
||||
|
||||
/**
|
||||
* Call the get sandbox method for a web project
|
||||
*/
|
||||
{
|
||||
Response response = sendRequest(new GetRequest(sandboxURL), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
sandboxref = data.getString("sandboxref");
|
||||
String url = data.getString("url");
|
||||
String name = data.getString("name");
|
||||
assertNotNull("sandboxref is null", sandboxref);
|
||||
assertNotNull("url is null", url);
|
||||
assertNotNull("name is null", name);
|
||||
|
||||
JSONObject createdDate = data.getJSONObject("createdDate");
|
||||
String createdOn = createdDate.getString("iso8601");
|
||||
String createdBy = data.getString("creator");
|
||||
assertNotNull("created date is null", createdOn );
|
||||
assertNotNull("created by is null", createdBy );
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test
|
||||
* Call the list sandbox method for a web project that does not exist
|
||||
*/
|
||||
{
|
||||
String invalidWebprojURL = "/api/wcm/webprojects/" + "twaddle" + "/sandboxes/" + sandboxref;
|
||||
sendRequest(new GetRequest(invalidWebprojURL), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test
|
||||
* Call the list sandbox method for a web project that does exist and a sandbox that doesn't
|
||||
*/
|
||||
{
|
||||
String invalidboxURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes/" + "twaddle";
|
||||
sendRequest(new GetRequest(invalidboxURL), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the delete sandbox method
|
||||
*/
|
||||
public void testDeleteSandbox() throws Exception
|
||||
{
|
||||
this.authenticationComponent.setCurrentUser("admin");
|
||||
String webprojref = createWebProject();
|
||||
|
||||
createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER);
|
||||
|
||||
/**
|
||||
* Create a sandbox
|
||||
*/
|
||||
JSONObject box = new JSONObject();
|
||||
box.put("userName", USER_ONE);
|
||||
String validURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes";
|
||||
Response response = sendRequest(new PostRequest(validURL, box.toString(), "application/json"), Status.STATUS_OK);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String sandboxref = data.getString("sandboxref");
|
||||
assertNotNull("sandboxref is null", sandboxref);
|
||||
|
||||
String sandboxURL = "/api/wcm/webprojects/" + webprojref + "/sandboxes/" + sandboxref;
|
||||
|
||||
/**
|
||||
* Negative test - web project not exist
|
||||
*/
|
||||
{
|
||||
String invalidProject = "/api/wcm/webprojects/" + "silly" + "/sandboxes/" + sandboxref;
|
||||
sendRequest(new DeleteRequest(invalidProject), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test - user sandbox not exist
|
||||
*/
|
||||
{
|
||||
String invalidSandbox = "/api/wcm/webprojects/" + webprojref + "/sandboxes/" + "silly";
|
||||
sendRequest(new DeleteRequest(invalidSandbox), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the sandbox - positive test
|
||||
*/
|
||||
{
|
||||
sendRequest(new DeleteRequest(sandboxURL), Status.STATUS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test
|
||||
* Delete the sandbox that has already been deleted
|
||||
*/
|
||||
|
||||
{
|
||||
sendRequest(new DeleteRequest(sandboxURL), Status.STATUS_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user