mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.1 to HEAD
12983: Merged V2.1-A to V3.1 8668: Added authorityDisplayName 12985: Merged V2.1-A to V3.1 8706: (record-only) Build fixes after removing the guest user - DO NOT MERGE 12990: Merged V3.0 to V3.1 12922: Merged V2.2 to V3.0 12555: Fix ETWOTWO-972 (Remove Lookup Cache) 12558: Fix ETWOTWO-978 (L2 Cache removal for No Row Issues) 12928: Merged V2.2 to V3.0 11319: Fix for ETWOTWO-73 (missed merge ?) ___________________________________________________________________ Modified: svn:mergeinfo Merged /alfresco/BRANCHES/V2.1-A:r8668,8706 Merged /alfresco/BRANCHES/V3.0:r12922,12928 Merged /alfresco/BRANCHES/V2.2:r12555,12558 Merged /alfresco/BRANCHES/V3.1:r12983,12985,12990 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13546 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.config.JNDIConstants;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -340,7 +341,7 @@ public final class SandboxFactory extends WCMUtil
|
||||
permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true);
|
||||
}
|
||||
|
||||
private void updateStagingAreaManagers(String storeId, NodeRef webProjectNodeRef, final List<String> managers)
|
||||
private void updateStagingAreaManagers(String storeId, final List<String> managers)
|
||||
{
|
||||
// The stores have the mask set in updateSandboxManagers
|
||||
String storeName = WCMUtil.buildStagingStoreName(storeId);
|
||||
@@ -931,9 +932,9 @@ public final class SandboxFactory extends WCMUtil
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSandboxManagers(final String wpStoreId, NodeRef wpNodeRef, List<String> managers)
|
||||
public void updateSandboxManagers(final String wpStoreId, List<String> managers)
|
||||
{
|
||||
// walk existing user sandboxes and reapply manager permissions to include new manager user
|
||||
// walk existing user sandboxes and reapply manager permissions to include new managers
|
||||
List<SandboxInfo> sbInfos = AuthenticationUtil.runAs(new RunAsWork<List<SandboxInfo>>()
|
||||
{
|
||||
public List<SandboxInfo> doWork() throws Exception
|
||||
@@ -951,7 +952,7 @@ public final class SandboxFactory extends WCMUtil
|
||||
}
|
||||
}
|
||||
|
||||
updateStagingAreaManagers(wpStoreId, wpNodeRef, managers);
|
||||
updateStagingAreaManagers(wpStoreId, managers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -985,6 +986,174 @@ public final class SandboxFactory extends WCMUtil
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSandboxManagers(final String wpStoreId, List<String> managers)
|
||||
{
|
||||
// walk existing user sandboxes and remove manager permissions to exclude old managers
|
||||
List<SandboxInfo> sbInfos = AuthenticationUtil.runAs(new RunAsWork<List<SandboxInfo>>()
|
||||
{
|
||||
public List<SandboxInfo> doWork() throws Exception
|
||||
{
|
||||
return listSandboxes(wpStoreId, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
for (SandboxInfo sbInfo : sbInfos)
|
||||
{
|
||||
if (sbInfo.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN))
|
||||
{
|
||||
String username = sbInfo.getName();
|
||||
removeUserSandboxManagers(wpStoreId, managers, username);
|
||||
}
|
||||
}
|
||||
|
||||
removeStagingAreaManagers(wpStoreId, managers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the permissions for the list of sandbox ex-managers.
|
||||
*
|
||||
* @param storeId The store id of the sandbox to update
|
||||
* @param managersToRemove The list of authorities who have had ContentManager role in the web project
|
||||
* @param username Username of the user sandbox to update
|
||||
*/
|
||||
private void removeUserSandboxManagers(String storeId, List<String> managersToRemove, String username)
|
||||
{
|
||||
final String userStoreName = WCMUtil.buildUserMainStoreName(storeId, username);
|
||||
final String previewStoreName = WCMUtil.buildUserPreviewStoreName(storeId, username);
|
||||
|
||||
final NodeRef mainDirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(userStoreName));
|
||||
final NodeRef previewDirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(previewStoreName));
|
||||
for (String manager : managersToRemove)
|
||||
{
|
||||
permissionService.deletePermission(mainDirRef.getStoreRef(), manager, WCMUtil.ROLE_CONTENT_MANAGER);
|
||||
permissionService.deletePermission(previewDirRef.getStoreRef(), manager, WCMUtil.ROLE_CONTENT_MANAGER);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Removes the ContentManager role on staging area to ex-managers.
|
||||
*
|
||||
* @param storeId The store id of the sandbox to update
|
||||
* @param managersToRemove The list of authorities who have had ContentManager role in the web project
|
||||
*/
|
||||
private void removeStagingAreaManagers(String storeId, List<String> managersToRemove)
|
||||
{
|
||||
final String storeName = WCMUtil.buildStagingStoreName(storeId);
|
||||
|
||||
final NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(storeName));
|
||||
for (String manager : managersToRemove)
|
||||
{
|
||||
permissionService.deletePermission(dirRef, manager, WCMUtil.ROLE_CONTENT_MANAGER);
|
||||
|
||||
permissionService.deletePermission(dirRef.getStoreRef(), manager,
|
||||
PermissionService.CHANGE_PERMISSIONS);
|
||||
permissionService.deletePermission(dirRef.getStoreRef(), manager,
|
||||
PermissionService.READ_PERMISSIONS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateSandboxRoles(final String wpStoreId, List<UserRoleWrapper> usersToUpdate, Set<String> permissionsList)
|
||||
{
|
||||
// walk existing user sandboxes and remove manager permissions to exclude old managers
|
||||
List<SandboxInfo> sbInfos = AuthenticationUtil.runAs(new RunAsWork<List<SandboxInfo>>()
|
||||
{
|
||||
public List<SandboxInfo> doWork() throws Exception
|
||||
{
|
||||
return listSandboxes(wpStoreId, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
for (SandboxInfo sbInfo : sbInfos)
|
||||
{
|
||||
if (sbInfo.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN))
|
||||
{
|
||||
String username = sbInfo.getName();
|
||||
updateUserSandboxRole(wpStoreId, username ,usersToUpdate, permissionsList);
|
||||
}
|
||||
}
|
||||
|
||||
updateStagingAreaRole(wpStoreId, usersToUpdate, permissionsList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates roles on the sandbox identified by username to users from usersToUpdate list.
|
||||
*
|
||||
* @param storeId The store id of the sandbox to update
|
||||
* @param username Username of the user sandbox to update
|
||||
* @param usersToUpdate The list of users who have role changes
|
||||
* @param permissionsList List of permissions @see org.alfresco.web.bean.wcm.InviteWebsiteUsersWizard.getPermissionsForType(). It is not mandatory.
|
||||
*/
|
||||
private void updateUserSandboxRole(String storeId, String username, List<UserRoleWrapper> usersToUpdate, Set<String> permissionsList)
|
||||
{
|
||||
final String userStoreName = WCMUtil.buildUserMainStoreName(storeId, username);
|
||||
final String previewStoreName = WCMUtil.buildUserPreviewStoreName(storeId, username);
|
||||
|
||||
final NodeRef mainDirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(userStoreName));
|
||||
final NodeRef previewDirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(previewStoreName));
|
||||
|
||||
// If permissionsList is set remove all possible user permissions and set only necessary.
|
||||
// This will fix previous wrong role changes. (paranoid)
|
||||
// For little better performance just set permissionsList to null.
|
||||
// But in this case it removes only previous permission.
|
||||
if (permissionsList != null && permissionsList.size() != 0)
|
||||
{
|
||||
for (UserRoleWrapper user : usersToUpdate)
|
||||
{
|
||||
for (String permission : permissionsList)
|
||||
{
|
||||
permissionService.deletePermission(mainDirRef, user.getUserAuth(), permission);
|
||||
permissionService.deletePermission(previewDirRef, user.getUserAuth(), permission);
|
||||
}
|
||||
|
||||
permissionService.setPermission(mainDirRef, user.getUserAuth(), user.getNewRole(), true);
|
||||
permissionService.setPermission(previewDirRef, user.getUserAuth(), user.getNewRole(), true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (UserRoleWrapper user: usersToUpdate)
|
||||
{
|
||||
permissionService.deletePermission(mainDirRef, user.getUserAuth(), user.getOldRole());
|
||||
permissionService.deletePermission(previewDirRef, user.getUserAuth(), user.getOldRole());
|
||||
permissionService.setPermission(mainDirRef, user.getUserAuth(), user.getNewRole(), true);
|
||||
permissionService.setPermission(previewDirRef, user.getUserAuth(), user.getNewRole(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates roles on staging sandbox to users from usersToUpdate list.
|
||||
*
|
||||
* @param storeId The store id of the sandbox to update
|
||||
* @param usersToUpdate The list of users who have role changes
|
||||
* @param permissionsList List of permissions @see org.alfresco.web.bean.wcm.InviteWebsiteUsersWizard.getPermissionsForType(). It is not mandatory.
|
||||
*/
|
||||
private void updateStagingAreaRole(String storeId, List<UserRoleWrapper> usersToUpdate, Set<String> permissionsList)
|
||||
{
|
||||
final String storeName = WCMUtil.buildStagingStoreName(storeId);
|
||||
final NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(storeName));
|
||||
|
||||
if (permissionsList != null && permissionsList.size() != 0)
|
||||
{
|
||||
for (UserRoleWrapper user : usersToUpdate)
|
||||
{
|
||||
for (String permission : permissionsList)
|
||||
{
|
||||
permissionService.deletePermission(dirRef, user.getUserAuth(), permission);
|
||||
}
|
||||
permissionService.setPermission(dirRef, user.getUserAuth(), user.getNewRole(), true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (UserRoleWrapper user : usersToUpdate)
|
||||
{
|
||||
permissionService.deletePermission(dirRef, user.getUserAuth(), user.getOldRole());
|
||||
permissionService.setPermission(dirRef, user.getUserAuth(), user.getNewRole(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag a named store with a DNS path meta-data attribute.
|
||||
* The DNS meta-data attribute is set to the system path 'store:/www/avm_webapps'
|
||||
@@ -1049,4 +1218,43 @@ public final class SandboxFactory extends WCMUtil
|
||||
logger.debug(" " + name + ": " + props.get(name));
|
||||
}
|
||||
}
|
||||
|
||||
public class UserRoleWrapper
|
||||
{
|
||||
private String newRole;
|
||||
private String oldRole;
|
||||
private String userAuth;
|
||||
|
||||
public UserRoleWrapper(String userAuth, String oldRole, String newRole)
|
||||
{
|
||||
this.userAuth = userAuth;
|
||||
this.oldRole = oldRole;
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
public String getNewRole()
|
||||
{
|
||||
return newRole;
|
||||
}
|
||||
public void setNewRole(String newRole)
|
||||
{
|
||||
this.newRole = newRole;
|
||||
}
|
||||
public String getOldRole()
|
||||
{
|
||||
return oldRole;
|
||||
}
|
||||
public void setOldRole(String oldRole)
|
||||
{
|
||||
this.oldRole = oldRole;
|
||||
}
|
||||
public String getUserAuth()
|
||||
{
|
||||
return userAuth;
|
||||
}
|
||||
public void setUserAuth(String userAuth)
|
||||
{
|
||||
this.userAuth = userAuth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user