Merged V3.2 to HEAD

19251:Merged V3.2.0 to V3.2
      19224: ALF-1999: Alfresco Explorer Group searches by display name now make correct use of AuthorityService
      19111: Final part of fix for ALF-1934 - show group 'display name' rather than group 'identifier'
   19088: Merged DEV/TEMPORARY to HEAD
      19005: Group Admin Scalability (SAP) implementation
      19078: ALF-1934: change the behaviour of 'Manage User Groups' similar to 'Manage System Users'


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19252 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2010-03-12 13:07:12 +00:00
parent 4b0ba5644c
commit 1cafe11ec8
3 changed files with 255 additions and 125 deletions

View File

@@ -828,6 +828,7 @@ system_props=System Properties
hide_details=Hide Details
show_details=Show Details
user_search_info=To find a user search for them using their first name, last name and/or user name. Alternatively to see all users click 'Show All', however, this may take some time if there are a lot of users in the system.
group_search_info=To find a group search for it using group name. Alternatively to see all groups click 'Show All', however, this may take some time if there are a lot of groups in the system.
user_change_homespace_info=Selecting a new home space for a user will not remove the existing permissions on the original home space. You may wish to use the Manage Space Users dialog to modify permissions if they are no longer required on the original home space.
quota_totalusage=Total Usage (for this search)
quota_totalquota=Total Quota (for this search)

View File

@@ -77,6 +77,9 @@ public class GroupsDialog extends BaseDialogBean
protected UIRichList groupsRichList;
protected UIRichList usersRichList;
/** Groups */
protected List<Map<String,String>> groups = Collections.<Map<String,String>> emptyList();
/** Currently visible Group Authority */
protected String group = null;
protected String groupName = null;
@@ -105,6 +108,9 @@ public class GroupsDialog extends BaseDialogBean
private static Log logger = LogFactory.getLog(GroupsDialog.class);
/** Groups search criteria */
private String groupsSearchCriteria = null;
// ------------------------------------------------------------------------------
// Construction
@@ -327,130 +333,191 @@ public class GroupsDialog extends BaseDialogBean
return this.location;
}
/**
* @return The list of group objects to display. Returns the list of root groups or the
* list of sub-groups for the current group if set.
*/
public List<Map> getGroups()
{
List<Map> groups;
/**
* @return true if user is in the root group
*/
public boolean isAllowSearchGroups()
{
return this.group == null;
}
UserTransaction tx = null;
try
{
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context);
tx.begin();
/**
* @return The list of group objects to display. Returns the list of root groups or the list of sub-groups for the current group if set.
*/
public List<Map<String,String>> getGroups()
{
if (this.group == null)
{
if (this.groups == null)
{
searchGroups();
}
}
else
{
if (this.groups == null)
{
showAllGroups();
}
}
return this.groups;
}
Set<String> authorities;
boolean immediate = (this.filterMode.equals(FILTER_CHILDREN));
if (this.group == null)
{
// root groups
if (immediate == true)
/**
* @return Returns the groups search criteria
*/
public String getGroupsSearchCriteria()
{
return groupsSearchCriteria;
}
/**
* Event handler called when the user wishes to search for a group
*
* @return The outcome
*/
public String searchGroups()
{
searchGroups(false);
// return null to stay on the same page
return null;
}
/**
* Action handler to show all the sub-groups in the group
*
* @return The outcome
*/
public String showAllGroups()
{
searchGroups(true);
// return null to stay on the same page
return null;
}
/**
* Searches groups
*
* @param all if true searches all groups and doesn't take account of search term
*/
private void searchGroups(boolean all)
{
groupsRichList.setValue(null);
String search = null;
// Use the search criteria if we are not searching for everything
if (!all)
{
if (this.groupsSearchCriteria == null)
{
authorities = this.getAuthorityService().getAllRootAuthoritiesInZone(AuthorityService.ZONE_APP_DEFAULT, AuthorityType.GROUP);
search = null;
}
else
{
authorities = this.getAuthorityService().getAllAuthoritiesInZone(AuthorityService.ZONE_APP_DEFAULT, AuthorityType.GROUP);
search = groupsSearchCriteria.trim();
if (search.length() == 0)
{
search = null;
}
else
{
// Let's make it search on the short name/display name prefix
search = search + "*";
}
}
}
else
{
// sub-group of an existing group
authorities = this.getAuthorityService().getContainedAuthorities(AuthorityType.GROUP, this.group, immediate);
}
groups = new ArrayList<Map>(authorities.size());
for (String authority : authorities)
{
Map<String, String> authMap = new HashMap<String, String>(3, 1.0f);
}
String name = this.getAuthorityService().getShortName(authority);
authMap.put("name", name);
authMap.put("id", authority);
authMap.put("group", authority);
authMap.put("groupName", name);
groups.add(authMap);
}
// commit the transaction
tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
groups = Collections.<Map>emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
return groups;
}
/**
* @return The list of user objects to display. Returns the list of user for the current group.
*/
public List<Map> getUsers()
{
List<Map> users;
UserTransaction tx = null;
try
{
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, true);
tx.begin();
Set<String> authorities;
if (this.group == null)
{
authorities = Collections.<String>emptySet();
}
else
{
// users of an existing group
if (!all && search == null)
{
// Do not allow empty searches
this.groups = Collections.<Map<String,String>> emptyList();
}
else
{
boolean immediate = (this.filterMode.equals(FILTER_CHILDREN));
authorities = this.getAuthorityService().getContainedAuthorities(AuthorityType.USER, this.group, immediate);
}
users = new ArrayList<Map>(authorities.size());
for (String authority : authorities)
{
Map<String, String> authMap = new HashMap<String, String>(3, 1.0f);
Set<String> authorities = this.authService.findAuthorities(AuthorityType.GROUP, this.group, immediate, search, AuthorityService.ZONE_APP_DEFAULT);
groups = new ArrayList<Map<String,String>>(authorities.size());
for (String authority : authorities)
{
Map<String, String> authMap = new HashMap<String, String>(11);
String userName = this.getAuthorityService().getShortName(authority);
authMap.put("userName", userName);
authMap.put("id", authority);
String name = this.authService.getAuthorityDisplayName(authority);
if (name == null)
{
name = this.authService.getShortName(name);
}
authMap.put("name", name);
authMap.put("id", authority);
authMap.put("group", authority);
authMap.put("groupName", name);
// get Person details for this Authority
NodeRef ref = this.getPersonService().getPerson(authority);
String firstName = (String)this.getNodeService().getProperty(ref, ContentModel.PROP_FIRSTNAME);
String lastName = (String)this.getNodeService().getProperty(ref, ContentModel.PROP_LASTNAME);
groups.add(authMap);
}
}
}
// build a sensible label for display
StringBuilder label = new StringBuilder(48);
label.append(firstName)
.append(' ')
.append(lastName != null ? lastName : "");
authMap.put("name", label.toString());
/**
* @return The list of user objects to display. Returns the list of user for the current group.
*/
public List<Map<String,String>> getUsers()
{
List<Map<String,String>> users;
users.add(authMap);
}
UserTransaction tx = null;
try
{
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, true);
tx.begin();
// commit the transaction
tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
users = Collections.<Map>emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
Set<String> authorities;
if (this.group == null)
{
authorities = Collections.<String>emptySet();
}
else
{
// users of an existing group
boolean immediate = (this.filterMode.equals(FILTER_CHILDREN));
authorities = this.getAuthorityService().getContainedAuthorities(AuthorityType.USER, this.group, immediate);
}
users = new ArrayList<Map<String,String>>(authorities.size());
for (String authority : authorities)
{
Map<String, String> authMap = new HashMap<String, String>(5);
return users;
}
String userName = this.getAuthorityService().getShortName(authority);
authMap.put("userName", userName);
authMap.put("id", authority);
// get Person details for this Authority
NodeRef ref = this.getPersonService().getPerson(authority);
String firstName = (String)this.getNodeService().getProperty(ref, ContentModel.PROP_FIRSTNAME);
String lastName = (String)this.getNodeService().getProperty(ref, ContentModel.PROP_LASTNAME);
// build a sensible label for display
StringBuilder label = new StringBuilder(48);
label.append(firstName)
.append(' ')
.append(lastName != null ? lastName : "");
authMap.put("name", label.toString());
users.add(authMap);
}
// commit the transaction
tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
users = Collections.<Map<String,String>>emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
return users;
}
/**
* Set the current Group Authority.
@@ -472,6 +539,7 @@ public class GroupsDialog extends BaseDialogBean
contextUpdated();
}
// ------------------------------------------------------------------------------
// Action handlers
@@ -488,10 +556,21 @@ public class GroupsDialog extends BaseDialogBean
{
// refresh UI based on node selection
updateUILocation(group);
setGroupsSearchCriteria(null);
}
}
/**
* Simple setter
*
* @param groupsSearchCriteria
*/
public void setGroupsSearchCriteria(String groupsSearchCriteria)
{
this.groupsSearchCriteria = groupsSearchCriteria;
}
/**
* Remove specified user from the current group
*/
public void removeUser(ActionEvent event)
@@ -525,9 +604,6 @@ public class GroupsDialog extends BaseDialogBean
}
}
// ------------------------------------------------------------------------------
// Helpers
/**
* Update the breadcrumb with the clicked Group location
*/
@@ -558,6 +634,7 @@ public class GroupsDialog extends BaseDialogBean
}
}
// ------------------------------------------------------------------------------
// IContextListener implementation
@@ -573,6 +650,7 @@ public class GroupsDialog extends BaseDialogBean
if (this.groupsRichList != null)
{
this.groupsRichList.setValue(null);
this.groups = null;
}
if (this.usersRichList != null)
@@ -597,6 +675,7 @@ public class GroupsDialog extends BaseDialogBean
// nothing to do
}
// ------------------------------------------------------------------------------
// Inner classes

View File

@@ -20,6 +20,33 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%@ page import="org.alfresco.web.ui.common.PanelGenerator"%>
<f:verbatim>
<script type="text/javascript">
window.onload = pageLoaded;
function pageLoaded()
{
document.getElementById("dialog:dialog-body:search-groups-text").focus();
updateGroupsButtonState();
}
function updateGroupsButtonState()
{
if (document.getElementById("dialog:dialog-body:search-groups-text").value.length == 0)
{
document.getElementById("dialog:dialog-body:search-groups-btn").disabled = true;
}
else
{
document.getElementById("dialog:dialog-body:search-groups-btn").disabled = false;
}
}
</script>
</f:verbatim>
<h:outputText value="<div style='padding-left: 8px; padding-top: 4px; padding-bottom: 4px'>" escape="false" />
@@ -31,7 +58,30 @@
<%-- Groups List --%>
<a:panel id="groups-panel" border="innerwhite" bgcolor="white" titleBorder="lbgrey" expandedTitleBorder="dotted" titleBgcolor="white" styleClass="mainSubTitle" label="#{msg.groups}">
<a:richList id="groups-list" binding="#{DialogManager.bean.groupsRichList}" viewMode="#{DialogManager.bean.viewMode}" pageSize="12"
<%-- Groups Search Panel --%>
<h:panelGroup rendered="#{DialogManager.bean.allowSearchGroups}">
<f:verbatim>
<%
PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc");
%>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td valign=top style="padding-top: 2px" width=20></f:verbatim><h:graphicImage url="/images/icons/info_icon.gif" width="16" height="16" /><f:verbatim></td>
<td class="mainSubText"></f:verbatim><h:outputText value="#{msg.group_search_info}" /><f:verbatim></td>
</tr>
</table>
<%
PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner");
%>
</f:verbatim>
<h:outputText value="</div><div style='padding: 8px;'>" escape="false" />
<h:inputText id="search-groups-text" value="#{DialogManager.bean.groupsSearchCriteria}" size="35" maxlength="1024" onkeyup="updateGroupsButtonState();" onchange="updateButtonState();" />&nbsp;
<h:commandButton id="search-groups-btn" value="#{msg.search}" action="#{DialogManager.bean.searchGroups}" disabled="true" />&nbsp;
<h:commandButton value="#{msg.show_all}" action="#{DialogManager.bean.showAllGroups}" />
<h:outputText value="</div><div style='padding: 4px;'>" escape="false" />
</h:panelGroup>
<a:richList id="groups-list" binding="#{DialogManager.bean.groupsRichList}" viewMode="#{DialogManager.bean.viewMode}" pageSize="12"
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
value="#{DialogManager.bean.groups}" var="r" initialSortColumn="name" initialSortDescending="true">
@@ -79,7 +129,7 @@
<%-- Users in Group list --%>
<a:panel id="users-panel" border="innerwhite" bgcolor="white" titleBorder="lbgrey" expandedTitleBorder="dotted" titleBgcolor="white" styleClass="mainSubTitle" label="#{msg.users}">
<a:richList id="users-list" binding="#{DialogManager.bean.usersRichList}" viewMode="#{DialogManager.bean.viewMode}" pageSize="12"
<a:richList id="users-list" binding="#{DialogManager.bean.usersRichList}" viewMode="#{DialogManager.bean.viewMode}" pageSize="12"
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
value="#{DialogManager.bean.users}" var="r" initialSortColumn="name" initialSortDescending="true">