From 0d435904175f1522d0e7a74f127a9fcb8b21122d Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 9 Jan 2007 12:22:38 +0000 Subject: [PATCH] . Inviting a Group into a website now creates sandboxes for all user authorities contained within the group - http://issues.alfresco.com/browse/WCM-76 . AVM file Version History list UI fixes and improvements . Fix to navigation (back and forward links) in AVM file/folder details page . More WCM UI enhancements from the usability review list git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4761 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 4 +- .../alfresco/web/bean/wcm/AVMDetailsBean.java | 4 +- .../web/bean/wcm/FileDetailsBean.java | 5 +- .../bean/wcm/InviteWebsiteUsersWizard.java | 128 ++++++++++++------ .../ui/wcm/component/UISandboxSnapshots.java | 6 +- source/web/jsp/wcm/file-details.jsp | 6 +- source/web/jsp/wcm/submit-dialog.jsp | 4 +- 7 files changed, 101 insertions(+), 56 deletions(-) diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 5f72ec0b02..8fe20dbeda 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -986,8 +986,8 @@ delete_sandbox=Delete Sandbox delete_sandbox_info=To remove this sandbox and the user from the Web Project, click OK. delete_sandbox_confirm=Are you sure you want to remove the user sandbox \"{0}\" from the Web Project? submit_submission_info=Submission Info -submit_comment=Comment -submit_snapshotlabel=Snapshot Label +submit_comment=Name +submit_snapshotlabel=Description submit_workflow_selection=Use the following workflow to submit all modified items submit_not_submit_warning=The following items cannot be submitted as they are already part of a workflow. submit_no_workflow_warning=No suitable workflows could be found for the modified items below diff --git a/source/java/org/alfresco/web/bean/wcm/AVMDetailsBean.java b/source/java/org/alfresco/web/bean/wcm/AVMDetailsBean.java index 8c14ff6d99..316e50cb09 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMDetailsBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMDetailsBean.java @@ -186,7 +186,7 @@ public abstract class AVMDetailsBean // reset - it does not know when the item has changed etc. for (int i=0; i> wrappers = new ArrayList>(history.size()); for (AVMNodeDescriptor record : history) { - Map wrapper = new HashMap(4, 1.0f); + Map wrapper = new HashMap(8, 1.0f); + wrapper.put("version", record.getVersionID()); wrapper.put("strVersion", Integer.toString(record.getVersionID())); wrapper.put("modifiedDate", new Date(record.getModDate())); @@ -165,6 +166,8 @@ public class FileDetailsBean extends AVMDetailsBean wrapper.put("url", DownloadContentServlet.generateBrowserURL( AVMNodeConverter.ToNodeRef(path.getFirst(), path.getSecond()), avmNode.getName())); } + wrapper.put("fileType16", Utils.getFileTypeImage(avmNode.getName(), true)); + wrappers.add(wrapper); } return wrappers; diff --git a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java index 5b5739a9b2..dfe387f7df 100644 --- a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java @@ -18,6 +18,7 @@ package org.alfresco.web.bean.wcm; import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -28,9 +29,9 @@ import java.util.Set; import javax.faces.context.FacesContext; import org.alfresco.model.WCMAppModel; -import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.web.app.Application; @@ -104,18 +105,22 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard // invited users and the power user who is executing the create web project wizard boolean foundCurrentUser = false; String currentUser = Application.getCurrentUser(context).getUserName(); + for (UserGroupRole userRole : this.userGroupRoles) { - String authority = userRole.getAuthority(); - if (currentUser.equals(authority)) + for (String userAuth : findNestedUserAuthorities(userRole.getAuthority())) { - foundCurrentUser = true; - } - if (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) - { - this.managers.add(authority); + if (currentUser.equals(userAuth)) + { + foundCurrentUser = true; + } + if (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) + { + this.managers.add(userAuth); + } } } + if (foundCurrentUser == false) { this.userGroupRoles.add(new UserGroupRole(currentUser, SandboxFactory.ROLE_CONTENT_MANAGER, null)); @@ -128,11 +133,15 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard // so retrieve the list of managers from the existing users and the selected invitees for (UserGroupRole userRole : this.userGroupRoles) { - if (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) + for (String userAuth : findNestedUserAuthorities(userRole.getAuthority())) { - this.managers.add(userRole.getAuthority()); + if (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) + { + this.managers.add(userAuth); + } } } + List userInfoRefs = this.nodeService.getChildAssocs( getNode().getNodeRef(), WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef ref : userInfoRefs) @@ -140,68 +149,99 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard NodeRef userInfoRef = ref.getChildRef(); String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE); + if (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userrole) && this.managers.contains(username) == false) { this.managers.add(username); } + // add each existing user to the exclude this - we cannot add them more than once! excludeUsers.add(username); } } // build the sandboxes now we have the manager list and complete user list + // and create an association to a node to represent each invited user List sandboxInfoList = new LinkedList(); - for (UserGroupRole userRole : this.userGroupRoles) { - String authority = userRole.getAuthority(); - if (excludeUsers.contains(authority) == false) + for (String userAuth : findNestedUserAuthorities(userRole.getAuthority())) { - SandboxInfo info = - SandboxFactory.createUserSandbox( - getAvmStore(), this.managers, userRole.getAuthority(), userRole.getRole()); - - sandboxInfoList.add( info ); - } - } - - // save the list of invited users against the store - for (UserGroupRole userRole : this.userGroupRoles) - { - String authority = userRole.getAuthority(); - if (excludeUsers.contains(authority) == false) - { - // create an app:webuser instance for each authority and assoc to the website node - Map props = new HashMap(2, 1.0f); - props.put(WCMAppModel.PROP_WEBUSERNAME, authority); - props.put(WCMAppModel.PROP_WEBUSERROLE, userRole.getRole()); - this.nodeService.createNode(getNode().getNodeRef(), - WCMAppModel.ASSOC_WEBUSER, - WCMAppModel.ASSOC_WEBUSER, - WCMAppModel.TYPE_WEBUSER, - props); + if (excludeUsers.contains(userAuth) == false) + { + SandboxInfo info = SandboxFactory.createUserSandbox( + getAvmStore(), this.managers, userAuth, userRole.getRole()); + + sandboxInfoList.add(info); + + // create an app:webuser instance for each authority and assoc to the website node + Map props = new HashMap(2, 1.0f); + props.put(WCMAppModel.PROP_WEBUSERNAME, userAuth); + props.put(WCMAppModel.PROP_WEBUSERROLE, userRole.getRole()); + this.nodeService.createNode(getNode().getNodeRef(), + WCMAppModel.ASSOC_WEBUSER, + WCMAppModel.ASSOC_WEBUSER, + WCMAppModel.TYPE_WEBUSER, + props); + } } } // reload virtualisation server for webapp in this web project if (isStandalone()) { - for (SandboxInfo sandboxInfo : sandboxInfoList ) + for (SandboxInfo sandboxInfo : sandboxInfoList) { - String newlyInvitedStoreName = - AVMConstants.buildStagingStoreName( sandboxInfo.getMainStoreName() ); - - String path = - AVMConstants.buildStoreWebappPath( newlyInvitedStoreName, - this.avmBrowseBean.getWebapp()); - + String newlyInvitedStoreName = AVMConstants.buildStagingStoreName(sandboxInfo.getMainStoreName()); + String path = AVMConstants.buildStoreWebappPath(newlyInvitedStoreName, this.avmBrowseBean.getWebapp()); AVMConstants.updateVServerWebapp(path, true); } } return outcome; } + + /** + * Find all nested user authorities contained with an authority + * + * @param authority The authority to search, USER authorities are returned immediately, GROUP authorites + * are recursively scanned for contained USER authorities. + * + * @return a Set of USER authorities + */ + private Set findNestedUserAuthorities(String authority) + { + Set users; + + AuthorityType authType = AuthorityType.getAuthorityType(authority); + if (authType.equals(AuthorityType.USER)) + { + users = new HashSet(1, 1.0f); + if (this.personService.personExists(authority) == true) + { + users.add(authority); + } + } + else if (authType.equals(AuthorityType.GROUP)) + { + // walk each member of the group + users = this.authorityService.getContainedAuthorities(AuthorityType.USER, authority, false); + for (String userAuth : users) + { + if (this.personService.personExists(userAuth) == false) + { + users.remove(authType); + } + } + } + else + { + users = Collections.emptySet(); + } + + return users; + } /** * @return summary text for the wizard diff --git a/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java b/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java index 73403f82f5..0bf3be03ed 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java @@ -66,7 +66,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent private static final String COMPONENT_ACTIONS = "org.alfresco.faces.Actions"; - private static final String MSG_LABEL = "label"; + private static final String MSG_LABEL = "name"; private static final String MSG_DESCRIPTION = "description"; private static final String MSG_DATE = "date"; private static final String MSG_USERNAME = "username"; @@ -204,8 +204,10 @@ public class UISandboxSnapshots extends SelfRenderingComponent versions = avmService.getStoreVersions(sandbox, fromDate, toDate); } Map requestMap = context.getExternalContext().getRequestMap(); - for (VersionDescriptor item : versions) + for (int i=versions.size() - 1; i >= 0; i--) // reverse order { + VersionDescriptor item = versions.get(i); + // only display snapshots with a valid tag - others are system generated snapshots if (item.getTag() != null && item.getVersionID() != 0) { diff --git a/source/web/jsp/wcm/file-details.jsp b/source/web/jsp/wcm/file-details.jsp index f8463711a4..8176c0ec5b 100644 --- a/source/web/jsp/wcm/file-details.jsp +++ b/source/web/jsp/wcm/file-details.jsp @@ -203,12 +203,12 @@ - - + + - + diff --git a/source/web/jsp/wcm/submit-dialog.jsp b/source/web/jsp/wcm/submit-dialog.jsp index 4d69aeff2c..96b034b1cf 100644 --- a/source/web/jsp/wcm/submit-dialog.jsp +++ b/source/web/jsp/wcm/submit-dialog.jsp @@ -60,10 +60,10 @@ - + - +