Build fix for breaking test case.

Bug fix invitation service was approving too many invitations! 
Implemented security rules for who is allowed to cancel a moderated invitation.
Continuing implementation of group authority scripts.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13815 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2009-04-02 16:35:31 +00:00
parent 3205b2c98c
commit 6b580c7cc4
7 changed files with 213 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
<#-- renders an authority object which can be either a GROUP or USER (and possibly ROLE in future)-->
<#macro formJSON authority>
<#macro authorityJSON authority>
<#escape x as jsonUtils.encodeJSONString(x)>
{
"authorityType" : "${authority.authorityType}",

View File

@@ -2,9 +2,12 @@
<shortname>List all root groups</shortname>
<description><![CDATA[
List all root groups.
If the optional includeInternal parameter is set then will include internal groups.
If the optional shortNameFilter parameter is set then returns those root groups with a partial match on shortName.
<br />
If the optional includeInternal parameter is set to 'true' then will include internal groups, if ommitted or 'false'
internal groups will not be returned.
<br />
If the optional shortNameFilter parameter is set then returns those root groups with a partial match on shortName.
The shortname filter can contain the wild card characters * and ? but these must be url encoded for this script.
]]>
</description>
<url>/api/rootgroups?shortNameFilter={shortNameFilter?}&amp;includeInternal={includeInternal?}</url>

View File

@@ -1 +1,25 @@
// get rootgroups
/**
* List/Search root groups
*/
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);
}
main();

View File

@@ -0,0 +1,11 @@
<#-- list / search / rootgroups -->
<#import "authority.lib.ftl" as authorityLib/>
{
"data": [
<#list groups as group>
<@authorityLib.authorityJSON authority=group />
<#if group_has_next>,</#if>
</#list>
]
}

View File

@@ -7,7 +7,9 @@
invitation which will result in the invitation workflow continuing to a normal but rejected conclusion.
In particular the approver or invitee are not notified if an invitation is canceled.
<BR>
Only a site manager may cancel an invitation.
Only a site manager may cancel an nominated invitation.
<BR>
A site manager or the invitee may cancel a moderated invitation.
<BR>
Returns 200, STATUS_OK on success.
]]>

View File

@@ -0,0 +1,166 @@
/*
* Copyright (C) 2005-2009 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.groups;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.site.SiteModel;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
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;
/**
* Unit test of Groups REST APIs.
*
* @author Mark Rogers
*/
public class GroupsTest extends BaseWebScriptTest
{
private AuthenticationService authenticationService;
private AuthenticationComponent authenticationComponent;
private PersonService personService;
private NodeService nodeService;
private static final String USER_ONE = "GroupTestOne";
private static final String USER_TWO = "GroupTestTwo";
private static final String USER_THREE = "GroupTestThree";
private static final String URL_GROUPS = "/api/groups";
private static final String URL_ROOTGROUPS = "/api/rootgroups";
@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.nodeService = (NodeService)getServer().getApplicationContext().getBean("NodeService");
this.authenticationComponent.setSystemUserAsCurrentUser();
// Create users
createUser(USER_ONE);
createUser(USER_TWO);
createUser(USER_THREE);
// 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);
}
}
@Override
protected void tearDown() throws Exception
{
super.tearDown();
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
}
/**
* Detailed test of get root groups
*/
public void testGetRootGroup() throws Exception
{
/**
* Get all root groups
*/
{
Response response = sendRequest(new GetRequest(URL_ROOTGROUPS), 200);
JSONObject top = new JSONObject(response.getContentAsString());
System.out.println(response.getContentAsString());
JSONArray data = top.getJSONArray("data");
}
}
/**
* Detailed test of get group
*/
public void testGetGroup()
{
}
/**
* Detailed test of create group
*/
public void testCreateGroup()
{
}
/**
* Detailed test of search groups
*/
public void testSearchGroups()
{
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 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