mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Site Service: refactor container API (Java & JS) to have separate create method, fix-up UI fallout, expose node details on site details (Java/JS/REST), fixup web scripts with correct permission levels
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9918 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -29,8 +29,12 @@ function findNodeInSite()
|
|||||||
var node = site.getContainer(containerId);
|
var node = site.getContainer(containerId);
|
||||||
if (node === null)
|
if (node === null)
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "Unable to fetch container '" + containerId + "' of site '" + siteId + "'. (No write permission?)");
|
node = site.createContainer(containerId);
|
||||||
return null;
|
if (node === null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "Unable to fetch container '" + containerId + "' of site '" + siteId + "'. (No write permission?)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to fetch the the path is there is any
|
// try to fetch the the path is there is any
|
||||||
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Get the membership details for a user</description>
|
<description>Get the membership details for a user</description>
|
||||||
<url>/api/sites/{shortname}/memberships/{username}</url>
|
<url>/api/sites/{shortname}/memberships/{username}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Get the membership details for a user</description>
|
<description>Get the membership details for a user</description>
|
||||||
<url>/api/sites/{shortname}/memberships/{username}</url>
|
<url>/api/sites/{shortname}/memberships/{username}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Get the membership details for a user</description>
|
<description>Get the membership details for a user</description>
|
||||||
<url>/api/sites/{shortname}/memberships/{username}</url>
|
<url>/api/sites/{shortname}/memberships/{username}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Get a colleciton of a sites memberships.</description>
|
<description>Get a colleciton of a sites memberships.</description>
|
||||||
<url>/api/sites/{shortname}/memberships?nf={namefilter?}&rf={rolefilter?}&size={pagesize?}&pos={position?}</url>
|
<url>/api/sites/{shortname}/memberships?nf={namefilter?}&rf={rolefilter?}&size={pagesize?}&pos={position?}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Adds a new membership to the site</description>
|
<description>Adds a new membership to the site</description>
|
||||||
<url>/api/sites/{shortname}/memberships</url>
|
<url>/api/sites/{shortname}/memberships</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Delete the details of a site.</description>
|
<description>Delete the details of a site.</description>
|
||||||
<url>/api/sites/{shortname}</url>
|
<url>/api/sites/{shortname}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Get the details of a site.</description>
|
<description>Get the details of a site.</description>
|
||||||
<url>/api/sites/{shortname}</url>
|
<url>/api/sites/{shortname}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -5,6 +5,10 @@
|
|||||||
"shortName" : "${site.shortName}",
|
"shortName" : "${site.shortName}",
|
||||||
"title" : "${site.title}",
|
"title" : "${site.title}",
|
||||||
"description" : "${site.description}",
|
"description" : "${site.description}",
|
||||||
|
<#if site.node?exists>
|
||||||
|
"node" : "${url.serviceContext}/api/node/${site.node.storeType}/${site.node.storeId}/${site.node.id}",
|
||||||
|
"tagScope" : "${url.serviceContext}/api/tagscopes/${site.node.storeType}/${site.node.storeId}/${site.node.id}",
|
||||||
|
</#if>
|
||||||
"isPublic" : ${site.isPublic?string("true", "false")}
|
"isPublic" : ${site.isPublic?string("true", "false")}
|
||||||
}
|
}
|
||||||
</#macro>
|
</#macro>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Update the details of a site.</description>
|
<description>Update the details of a site.</description>
|
||||||
<url>/api/sites/{shortname}</url>
|
<url>/api/sites/{shortname}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Get a colleciton of the sites in the repository. The collection can be filtered by name and/or site preset.</description>
|
<description>Get a colleciton of the sites in the repository. The collection can be filtered by name and/or site preset.</description>
|
||||||
<url>/api/sites?nf={namefilter?}&spf={sitepresetfilter?}&size={pagesize?}&pos={position?}</url>
|
<url>/api/sites?nf={namefilter?}&spf={sitepresetfilter?}&size={pagesize?}&pos={position?}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -3,6 +3,6 @@
|
|||||||
<description>Creates a new site based on the site preset and details provided.</description>
|
<description>Creates a new site based on the site preset and details provided.</description>
|
||||||
<url>/api/sites</url>
|
<url>/api/sites</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -17,19 +17,20 @@ function findTargetNode()
|
|||||||
}
|
}
|
||||||
else if (containerId == undefined)
|
else if (containerId == undefined)
|
||||||
{
|
{
|
||||||
// PENDING: hack!
|
// get site node
|
||||||
// site is not a node reference, which we need though to get the tagscope.
|
return site.node;
|
||||||
// simply take a container we know it exists and fetch the parent
|
|
||||||
return site.getContainer("blog").parent;
|
|
||||||
//return site;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch container
|
// fetch container
|
||||||
node = site.getContainer(containerId);
|
node = site.getContainer(containerId);
|
||||||
if (node === null)
|
if (node === null)
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "Unable to fetch container '" + containerId + "' of site '" + siteId + "'. (No write permission?)");
|
node = site.createContainer(containerId);
|
||||||
return null;
|
if (node === null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "Unable to fetch container '" + containerId + "' of site '" + siteId + "'. (No write permission?)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (path == undefined)
|
else if (path == undefined)
|
||||||
{
|
{
|
||||||
|
@@ -4,6 +4,6 @@
|
|||||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
||||||
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -4,6 +4,6 @@
|
|||||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}?qc={queuecreate?}&ph={placeholder?}</url>
|
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}?qc={queuecreate?}&ph={placeholder?}</url>
|
||||||
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}?qc={queuecreate?}&ph={placeholder?}</url>
|
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}?qc={queuecreate?}&ph={placeholder?}</url>
|
||||||
<format default="">argument</format>
|
<format default="">argument</format>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -13,7 +13,7 @@ function main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the thumbnail name from the JSON content
|
// Get the thumbnail name from the JSON content
|
||||||
var thumbnailName = url.templateArgs.thumbnailname; //pathSegments[pathSegments.length - 1];
|
var thumbnailName = url.templateArgs.thumbnailname;
|
||||||
|
|
||||||
// 404 if no thumbnail name found
|
// 404 if no thumbnail name found
|
||||||
if (thumbnailName == null)
|
if (thumbnailName == null)
|
||||||
|
@@ -4,6 +4,6 @@
|
|||||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
||||||
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails/{thumbnailname}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -4,6 +4,6 @@
|
|||||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails?as={async?}</url>
|
<url>/api/node/{store_type}/{store_id}/{id}/content{property}/thumbnails?as={async?}</url>
|
||||||
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails?as={async?}</url>
|
<url>/api/path/{store_type}/{store_id}/{id}/content{property}/thumbnails?as={async?}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>guest</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
</webscript>
|
</webscript>
|
@@ -96,6 +96,11 @@ else
|
|||||||
{
|
{
|
||||||
// Upload mode, since uploadDirectory was used
|
// Upload mode, since uploadDirectory was used
|
||||||
var container = site.getContainer(containerId);
|
var container = site.getContainer(containerId);
|
||||||
|
if (container === null)
|
||||||
|
{
|
||||||
|
container = site.createContainer(containerId);
|
||||||
|
}
|
||||||
|
|
||||||
if (container === null)
|
if (container === null)
|
||||||
{
|
{
|
||||||
status.code = 404;
|
status.code = 404;
|
||||||
|
@@ -23,7 +23,11 @@ function deleteEvent()
|
|||||||
var eventsFolder = site.getContainer("calendar");
|
var eventsFolder = site.getContainer("calendar");
|
||||||
if (eventsFolder === null)
|
if (eventsFolder === null)
|
||||||
{
|
{
|
||||||
return status.STATUS_NOT_FOUND;
|
eventsFolder = site.createContainer("calendar");
|
||||||
|
if (eventsFolder === null)
|
||||||
|
{
|
||||||
|
return status.STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var event = eventsFolder.childByNamePath(params.eventname);
|
var event = eventsFolder.childByNamePath(params.eventname);
|
||||||
|
@@ -56,7 +56,11 @@ function main()
|
|||||||
var eventsFolder = site.getContainer("calendar");
|
var eventsFolder = site.getContainer("calendar");
|
||||||
if (eventsFolder === null)
|
if (eventsFolder === null)
|
||||||
{
|
{
|
||||||
return jsonError("Could not locate events container");
|
eventsFolder = site.createContainer("calendar");
|
||||||
|
if (eventsFolder === null)
|
||||||
|
{
|
||||||
|
return jsonError("Could not locate events container");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var event = eventsFolder.childByNamePath(params.eventname);
|
var event = eventsFolder.childByNamePath(params.eventname);
|
||||||
|
@@ -52,9 +52,13 @@ function createEvent(siteId, params)
|
|||||||
var calendar = site.getContainer("calendar");
|
var calendar = site.getContainer("calendar");
|
||||||
if (calendar === null)
|
if (calendar === null)
|
||||||
{
|
{
|
||||||
return {
|
calendar = site.createContainer("calendar");
|
||||||
"error": "Could not get container"
|
if (calendar === null)
|
||||||
};
|
{
|
||||||
|
return {
|
||||||
|
"error": "Could not get container"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!calendar.isTagScope)
|
if (!calendar.isTagScope)
|
||||||
|
@@ -43,7 +43,11 @@ function main()
|
|||||||
var eventsFolder = site.getContainer("calendar");
|
var eventsFolder = site.getContainer("calendar");
|
||||||
if (eventsFolder === null)
|
if (eventsFolder === null)
|
||||||
{
|
{
|
||||||
return status.STATUS_NOT_FOUND;
|
eventsFolder = site.createContainer("calendar");
|
||||||
|
if (eventsFolder === null)
|
||||||
|
{
|
||||||
|
return status.STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var event = eventsFolder.childByNamePath(params.eventname);
|
var event = eventsFolder.childByNamePath(params.eventname);
|
||||||
|
@@ -14,7 +14,11 @@ function getEvents(siteId)
|
|||||||
var calendar = site.getContainer("calendar");
|
var calendar = site.getContainer("calendar");
|
||||||
if (calendar === null)
|
if (calendar === null)
|
||||||
{
|
{
|
||||||
return [];
|
calendar = site.createContainer("calendar");
|
||||||
|
if (calendar === null)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!calendar.isTagScope)
|
if (!calendar.isTagScope)
|
||||||
|
@@ -25,7 +25,11 @@ function getDocs(siteId, filter)
|
|||||||
var parentNode = site.getContainer("documentLibrary");
|
var parentNode = site.getContainer("documentLibrary");
|
||||||
if (parentNode === null)
|
if (parentNode === null)
|
||||||
{
|
{
|
||||||
return jsonError("Document Library container not found in: " + siteId + ". (No write permission?)");
|
parentNode = site.createContainer("documentLibrary");
|
||||||
|
if (parentNode === null)
|
||||||
|
{
|
||||||
|
return jsonError("Document Library container not found in: " + siteId + ". (No write permission?)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// build up the query to get documents modified in the last 7 days
|
// build up the query to get documents modified in the last 7 days
|
||||||
|
@@ -285,7 +285,11 @@ function getRootNode(p_params)
|
|||||||
rootNode = siteNode.getContainer(p_params.containerId);
|
rootNode = siteNode.getContainer(p_params.containerId);
|
||||||
if (rootNode === null)
|
if (rootNode === null)
|
||||||
{
|
{
|
||||||
return "Component container '" + p_params.containerId + "' not found in '" + p_params.siteId + "'.";
|
rootNode = siteNode.createContainer(p_params.containerId);
|
||||||
|
if (rootNode === null)
|
||||||
|
{
|
||||||
|
return "Component container '" + p_params.containerId + "' not found in '" + p_params.siteId + "'.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(e)
|
catch(e)
|
||||||
|
@@ -33,8 +33,12 @@ function getParsedArgs()
|
|||||||
rootNode = siteNode.getContainer(container);
|
rootNode = siteNode.getContainer(container);
|
||||||
if (rootNode === null)
|
if (rootNode === null)
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "Document Library container '" + container + "' not found in '" + site + "'. (No permission?)");
|
rootNode = siteNode.createContainer(container);
|
||||||
return null;
|
if (rootNode === null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "Document Library container '" + container + "' not found in '" + site + "'. (No permission?)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,8 +31,12 @@ function main()
|
|||||||
var wiki = site.getContainer("wiki");
|
var wiki = site.getContainer("wiki");
|
||||||
if (wiki === null)
|
if (wiki === null)
|
||||||
{
|
{
|
||||||
return jsonError("Could not locate wiki");
|
wiki = site.createContainer("wiki");
|
||||||
}
|
if (wiki === null)
|
||||||
|
{
|
||||||
|
return jsonError("Could not locate wiki");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var page = wiki.childByNamePath(params.pageTitle);
|
var page = wiki.childByNamePath(params.pageTitle);
|
||||||
if (!page)
|
if (!page)
|
||||||
|
@@ -22,13 +22,17 @@ function deleteEvent()
|
|||||||
status.setCode(status.STATUS_NOT_FOUND, "Could not find site.");
|
status.setCode(status.STATUS_NOT_FOUND, "Could not find site.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var wiki = site.getContainer("wiki");
|
var wiki = site.getContainer("wiki");
|
||||||
if (wiki === null)
|
if (wiki === null)
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "Could not find wiki container.");
|
wiki = site.createContainer("wiki");
|
||||||
return;
|
if (wiki === null)
|
||||||
}
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "Could not find wiki container.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var page = wiki.childByNamePath(params.pageTitle);
|
var page = wiki.childByNamePath(params.pageTitle);
|
||||||
if (page === null)
|
if (page === null)
|
||||||
|
@@ -50,8 +50,12 @@ function main()
|
|||||||
var wiki = site.getContainer("wiki");
|
var wiki = site.getContainer("wiki");
|
||||||
if (wiki === null)
|
if (wiki === null)
|
||||||
{
|
{
|
||||||
//return jsonError("Could not locate wiki container");
|
wiki = site.createContainer("wiki");
|
||||||
return null;
|
if (wiki === null)
|
||||||
|
{
|
||||||
|
//return jsonError("Could not locate wiki container");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wiki.isTagScope)
|
if (!wiki.isTagScope)
|
||||||
|
@@ -47,7 +47,11 @@ function update()
|
|||||||
var wiki = site.getContainer("wiki");
|
var wiki = site.getContainer("wiki");
|
||||||
if (wiki === null)
|
if (wiki === null)
|
||||||
{
|
{
|
||||||
return jsonError("Could not locate wiki container");
|
wiki = site.createContainer("wiki");
|
||||||
|
if (wiki === null)
|
||||||
|
{
|
||||||
|
return jsonError("Could not locate wiki container");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var page = wiki.childByNamePath(params.pageTitle);
|
var page = wiki.childByNamePath(params.pageTitle);
|
||||||
|
@@ -22,8 +22,12 @@ function getWikiPages(siteId)
|
|||||||
var wiki = site.getContainer("wiki");
|
var wiki = site.getContainer("wiki");
|
||||||
if (wiki === null)
|
if (wiki === null)
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "Wiki container not found");
|
wiki = site.createContainer("wiki");
|
||||||
return;
|
if (wiki === null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "Wiki container not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wiki.isTagScope)
|
if (!wiki.isTagScope)
|
||||||
|
@@ -120,6 +120,8 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
assertEquals(shortName, result.get("shortName"));
|
assertEquals(shortName, result.get("shortName"));
|
||||||
assertEquals("myTitle", result.get("title"));
|
assertEquals("myTitle", result.get("title"));
|
||||||
assertEquals("myDescription", result.get("description"));
|
assertEquals("myDescription", result.get("description"));
|
||||||
|
assertNotNull(result.get("node"));
|
||||||
|
assertNotNull(result.get("tagScope"));
|
||||||
assertTrue(result.getBoolean("isPublic"));
|
assertTrue(result.getBoolean("isPublic"));
|
||||||
|
|
||||||
// Check for duplicate names
|
// Check for duplicate names
|
||||||
|
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2007 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.tagging;
|
||||||
|
|
||||||
|
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.service.cmr.tagging.TaggingService;
|
||||||
|
import org.alfresco.util.PropertyMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test to test tagging Web Script API
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
*/
|
||||||
|
public class TaggingServiceTest extends BaseWebScriptTest
|
||||||
|
{
|
||||||
|
private AuthenticationService authenticationService;
|
||||||
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
private PersonService personService;
|
||||||
|
private TaggingService taggingService;
|
||||||
|
|
||||||
|
private static final String TEST_USER = "TaggingServiceTestUser";
|
||||||
|
|
||||||
|
|
||||||
|
@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");
|
||||||
|
this.taggingService = (TaggingService)getServer().getApplicationContext().getBean("TaggingService");
|
||||||
|
|
||||||
|
// Create users
|
||||||
|
createUser(TEST_USER);
|
||||||
|
|
||||||
|
// Do tests as user one
|
||||||
|
this.authenticationComponent.setCurrentUser(TEST_USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception
|
||||||
|
{
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getTagsTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user