Site Service: GET, PUT and DELETE methods implemented and unit tested for Membership resource

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9063 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-05-10 00:27:11 +00:00
parent 63674f3e8d
commit 344b703a61
3 changed files with 99 additions and 3 deletions

View File

@@ -35,16 +35,73 @@ public interface SiteService
// TODO audit information
List<SiteInfo> listSites(String nameFilter, String sitePresetFilter);
/**
* Gets site information based on the short name of a site.
* <p>
* Returns null if the site can not be found.
*
* @param shortName the site short name
* @return SiteInfo the site information
*/
SiteInfo getSite(String shortName);
/**
* Update the site information.
* <P>
* Note that the shortname and sitepreset of a site can not be updated once the site has been created.
*
* @param siteInfo site information
*/
void updateSite(SiteInfo siteInfo);
/**
* Delete the site.
*
* @param shortName site short name
*/
void deleteSite(String shortName);
/**
* List the memebers of the site.
* <p>
* Name and role filters are optional and if not specified all the memebers of the site are returned.
*
* @param shortName site short name
* @param nameFilter name filter
* @param roleFilter role filter
* @return Map<String, String> the username and their role
*/
Map<String, String> listMembers(String shortName, String nameFilter, String roleFilter);
/**
*
* @param shortName
* @param userName
* @return
*/
String getMembersRole(String shortName, String userName);
/**
*
* @param shortName
* @param userName
* @return
*/
boolean isMember(String shortName, String userName);
/**
*
* @param shortName
* @param userName
* @param role
*/
void setMembership(String shortName, String userName, String role);
/**
*
* @param shortName
* @param userName
*/
void removeMembership(String shortName, String userName);

View File

@@ -310,7 +310,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
}
else
{
// CHeck to see if we already have an entry for the user in the map
// Check to see if we already have an entry for the user in the map
if (members.containsKey(authority) == true)
{
// TODO .. we need to resolve the permission in the map to the 'highest'
@@ -327,6 +327,23 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
return members;
}
/**
* @see org.alfresco.repo.site.SiteService#getMembersRole(java.lang.String, java.lang.String)
*/
public String getMembersRole(String shortName, String userName)
{
Map<String, String> members = listMembers(shortName, null, null);
return members.get(userName);
}
/**
* @see org.alfresco.repo.site.SiteService#isMember(java.lang.String, java.lang.String)
*/
public boolean isMember(String shortName, String userName)
{
return (getMembersRole(shortName, userName) != null);
}
/**
* @see org.alfresco.repo.site.SiteService#removeMembership(java.lang.String, java.lang.String)
*/

View File

@@ -30,8 +30,6 @@ import java.util.Map;
import org.alfresco.repo.jscript.ScriptableHashMap;
import org.alfresco.repo.site.SiteInfo;
import org.alfresco.repo.site.SiteService;
import org.jgroups.util.GetNetworkInterfaces1_4;
import org.mozilla.javascript.ScriptableObject;
/**
* Site JavaScript object
@@ -192,6 +190,30 @@ public class Site implements Serializable
return result;
}
/**
* Gets a user's role on this site.
* <p>
* If the user is not a member of the site then null is returned.
*
* @param userName user name
* @return String user's role or null if not a member
*/
public String getMembersRole(String userName)
{
return this.siteService.getMembersRole(getShortName(), userName);
}
/**
* Indicates whether a user is a member of the site.
*
* @param userName user name
* @return boolean true if the user is a member of the site, false otherwise
*/
public boolean isMember(String userName)
{
return this.siteService.isMember(getShortName(), userName);
}
/**
* Sets the membership details for a user.
* <p>