. User permissions now applied during Create Website wizard

- Content Managers have access to all sandboxes, including staging sandbox
 - Other invited users have appropriate permissions as per their role
 - Users (except managers) are now restricted to making changes within their own sandbox - and commiting those changes
 - TODO: add evaluators to hide inappropriate actions for users
. Minor bug fixes to Create XML Form wizard

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4041 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-10-05 18:05:08 +00:00
parent bdb85b693a
commit fe50122847
3 changed files with 73 additions and 39 deletions

View File

@@ -67,6 +67,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
private String websitesFolderId = null;
protected AVMService avmService;
protected PermissionService permissionService;
// ------------------------------------------------------------------------------
@@ -116,28 +117,40 @@ public class CreateWebsiteWizard extends BaseWizardBean
wiz.setNode(new Node(nodeRef));
outcome = wiz.finish();
if (outcome != null)
{
// create the AVM stores to represent the newly created location website
createStagingSandbox(this.name);
{
// create a sandbox for each user appropriately with permissions based on role
// build a list of managers who will have full permissions on ALL staging areas
List<String> managers = new ArrayList<String>(4);
boolean foundCurrentUser = false;
List<UserGroupRole> invitedUserRoles = (List<UserGroupRole>)wiz.getUserRolesDataModel().getWrappedData();
String currentUser = Application.getCurrentUser(context).getUserName();
for (UserGroupRole userRole : invitedUserRoles)
{
if (currentUser.equals(userRole.getAuthority()))
String authority = userRole.getAuthority();
if (currentUser.equals(authority))
{
foundCurrentUser = true;
}
createUserSandbox(this.name, userRole.getAuthority(), userRole.getRole());
if (ROLE_CONTENT_MANAGER.equals(userRole))
{
managers.add(authority);
}
}
if (foundCurrentUser == false)
{
createUserSandbox(this.name, currentUser, ROLE_CONTENT_MANAGER);
invitedUserRoles.add(new UserGroupRole(currentUser, ROLE_CONTENT_MANAGER, null));
managers.add(currentUser);
}
// build the sandboxes now we have the manager list and complete user list
for (UserGroupRole userRole : invitedUserRoles)
{
createUserSandbox(this.name, managers, userRole.getAuthority(), userRole.getRole());
}
// create the AVM stores to represent the newly created location website
createStagingSandbox(this.name, managers);
// save the list of invited users against the store
for (UserGroupRole userRole : invitedUserRoles)
{
@@ -170,6 +183,14 @@ public class CreateWebsiteWizard extends BaseWizardBean
{
this.avmService = avmService;
}
/**
* @param permissionService The permissionService to set.
*/
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
/**
* @return Returns the name.
@@ -308,8 +329,9 @@ public class CreateWebsiteWizard extends BaseWizardBean
* Website Name: .website.name = website name
*
* @param name The store name to create the sandbox for
* @param managers The list of authorities who have ContentManager role in the website
*/
private void createStagingSandbox(String name)
private void createStagingSandbox(String name, List<String> managers)
{
// create the 'staging' store for the website
String stagingStore = AVMConstants.buildAVMStagingStoreName(name);
@@ -319,11 +341,16 @@ public class CreateWebsiteWizard extends BaseWizardBean
// create the system directories 'appBase' and 'avm_webapps'
String path = stagingStore + ":/";
this.avmService.createDirectory(path, AVMConstants.DIR_APPBASE);
//this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_APPBASE, ContentModel.TYPE_AVM_PLAIN_FOLDER);
this.avmService.createDirectory(path, AVMConstants.DIR_APPBASE);
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
for (String manager : managers)
{
this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
}
path += AVMConstants.DIR_APPBASE;
this.avmService.createDirectory(path, AVMConstants.DIR_WEBAPPS);
//this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_WEBAPPS, ContentModel.TYPE_AVM_PLAIN_FOLDER);
this.avmService.createDirectory(path, AVMConstants.DIR_WEBAPPS);
// tag the store with the store type
this.avmService.setStoreProperty(stagingStore,
@@ -342,8 +369,13 @@ public class CreateWebsiteWizard extends BaseWizardBean
// create a layered directory pointing to 'appBase' in the staging area
path = previewStore + ":/";
String targetPath = name + AVMConstants.STORE_STAGING + ":/" + AVMConstants.DIR_APPBASE;
this.avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
//this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_APPBASE, ContentModel.TYPE_AVM_PLAIN_FOLDER);
this.avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
for (String manager : managers)
{
this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
}
// tag the store with the store type
this.avmService.setStoreProperty(previewStore,
@@ -384,10 +416,11 @@ public class CreateWebsiteWizard extends BaseWizardBean
* Website Name: .website.name = website name
*
* @param name The store name to create the sandbox for
* @param managers The list of authorities who have ContentManager role in the website
* @param username Username of the user to create the sandbox for
* @param role Role permission for the user
*/
private void createUserSandbox(String name, String username, String role)
private void createUserSandbox(String name, List<String> managers, String username, String role)
{
// create the user 'main' store
String userStore = AVMConstants.buildAVMUserMainStoreName(name, username);
@@ -399,12 +432,18 @@ public class CreateWebsiteWizard extends BaseWizardBean
String path = userStore + ":/";
String targetPath = name + AVMConstants.STORE_STAGING + ":/" + AVMConstants.DIR_APPBASE;
this.avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
this.permissionService.setPermission(dirRef, username, role, true);
for (String manager : managers)
{
this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
}
// tag the store with the store type
this.avmService.setStoreProperty(userStore,
QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_MAIN),
new PropertyValue(DataTypeDefinition.TEXT, null));
// tag the store with the base name of the website so that corresponding
// staging areas can be found.
this.avmService.setStoreProperty(userStore,
@@ -431,6 +470,12 @@ public class CreateWebsiteWizard extends BaseWizardBean
path = previewStore + ":/";
targetPath = userStore + ":/" + AVMConstants.DIR_APPBASE;
this.avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
this.permissionService.setPermission(dirRef, username, role, true);
for (String manager : managers)
{
this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
}
// tag the store with the store type
this.avmService.setStoreProperty(previewStore,