mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
64403: Merged WAT1 (4.3/Cloud) to HEAD-BUG-FIX (4.3/Cloud) 61444: ACE-563: Added SITE_ADMINISTRATORS group as well as a patch. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@64549 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* A patch to add a new group authority.
|
||||
*
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*/
|
||||
public class AddGroupAuthorityPatch extends AbstractPatch
|
||||
{
|
||||
private static final String MSG_START = "patch.addGroupAuthority.start";
|
||||
private static final String MSG_RESULT = "patch.addGroupAuthority.result";
|
||||
|
||||
private AuthorityService authorityService;
|
||||
private GroupAuthorityDetails groupAuthorityDetails;
|
||||
|
||||
/**
|
||||
* Sets the authority service.
|
||||
*
|
||||
* @param authorityService the authority service
|
||||
*/
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the group authority details.
|
||||
*
|
||||
* @param groupAuthorityDetails the groupAuthorityDetails
|
||||
*/
|
||||
public void setGroupAuthorityDetails(GroupAuthorityDetails groupAuthorityDetails)
|
||||
{
|
||||
this.groupAuthorityDetails = groupAuthorityDetails;
|
||||
}
|
||||
|
||||
protected void checkProperties()
|
||||
{
|
||||
super.checkProperties();
|
||||
checkPropertyNotNull(authorityService, "authorityService");
|
||||
checkPropertyNotNull(groupAuthorityDetails, "groupAuthorityDetails");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
StringBuilder result = new StringBuilder(I18NUtil.getMessage(MSG_START));
|
||||
|
||||
String groupAuthorityName = authorityService.createAuthority(AuthorityType.GROUP,
|
||||
this.groupAuthorityDetails.groupName,
|
||||
this.groupAuthorityDetails.groupDisplayName,
|
||||
this.groupAuthorityDetails.authorityZones);
|
||||
|
||||
if (this.groupAuthorityDetails.adminUserName != null
|
||||
&& authorityService.isAdminAuthority(this.groupAuthorityDetails.adminUserName))
|
||||
{
|
||||
// Add admin as a member of the created group
|
||||
authorityService.addAuthority(groupAuthorityName,
|
||||
this.groupAuthorityDetails.adminUserName);
|
||||
}
|
||||
result.append(I18NUtil.getMessage(MSG_RESULT, groupAuthorityName));
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple POJO to encapsulate the group authority details.
|
||||
*
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*/
|
||||
public static class GroupAuthorityDetails
|
||||
{
|
||||
private String groupName;
|
||||
private String groupDisplayName;
|
||||
private String adminUserName;
|
||||
private Set<String> authorityZones;
|
||||
|
||||
/**
|
||||
* @param groupName the groupName to set
|
||||
*/
|
||||
public void setGroupName(String groupName)
|
||||
{
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupDisplayName the groupDisplayName to set
|
||||
*/
|
||||
public void setGroupDisplayName(String groupDisplayName)
|
||||
{
|
||||
this.groupDisplayName = groupDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Admin's username, so it can be included as a member of the
|
||||
* group. If null, an empty group will be created.
|
||||
*
|
||||
* @param adminUserName the adminUserName to set
|
||||
*/
|
||||
public void setAdminUserName(String adminUserName)
|
||||
{
|
||||
this.adminUserName = adminUserName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authorityZones the authorityZones to set
|
||||
*/
|
||||
public void setAuthorityZones(Set<String> authorityZones)
|
||||
{
|
||||
this.authorityZones = authorityZones;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user