Merged V2.1-A to HEAD

8403: Fix for ADB-33
  8586: Fix for ADB-33

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9192 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2008-05-21 09:05:00 +00:00
parent a4937fd9ae
commit c5220e3a96
7 changed files with 137 additions and 5 deletions

View File

@@ -602,6 +602,8 @@ space_owner=User ''{0}'' is the current owner of this space.
users_and_groups=Users and Groups
authority=Username
invite_users_summary=Users and Roles
too_many_users=Too many users matched by your search. Please narrow your search and try again.
max_users_returned=Search has been limited to show first {0} results.
# Invite Content Users Wizard messages
invite_content_title=Invite Content Users Wizard

View File

@@ -51,6 +51,9 @@
<!-- Limit search results within selectors, -1 for unlimited. -->
<selectors-search-max-results>500</selectors-search-max-results>
<!-- Limit search results within invite users wizard, -1 for unlimited. -->
<invite-users-max-results>500</invite-users-max-results>
<!-- The path to starting point when creating/finding home folders for new users in the UI -->
<default-home-space-path>/app:company_home/app:user_homes</default-home-space-path>

View File

@@ -54,6 +54,7 @@ import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.SortableSelectItem;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIGenericPicker;
import org.apache.lucene.search.BooleanQuery;
/**
* Implementation of the add user dialog.
@@ -244,6 +245,15 @@ public class AddUsersDialog extends BaseDialogBean
}
});
}
catch (BooleanQuery.TooManyClauses clauses)
{
Utils.addErrorMessage(Application.getMessage(
FacesContext.getCurrentInstance(), "too_many_users"));
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
return new SelectItem[0];
}
catch (Exception err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(

View File

@@ -46,7 +46,9 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.impl.lucene.QueryParser;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
@@ -61,6 +63,9 @@ import org.alfresco.web.bean.repository.User;
import org.alfresco.web.ui.common.SortableSelectItem;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIGenericPicker;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.search.BooleanQuery;
import org.springframework.mail.javamail.JavaMailSender;
/**
@@ -72,12 +77,15 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
{
private static final long serialVersionUID = -5145813383038390250L;
private final static Log logger = LogFactory.getLog(BaseInviteUsersWizard.class);
/** I18N message strings */
protected static final String MSG_USERROLES = "invite_users_summary";
private static final String MSG_USERS = "users";
private static final String MSG_GROUPS = "groups";
private static final String MSG_INVITED_TO = "invited_to";
private static final String MSG_INVITED_ROLE = "invite_role";
private static final String MSG_MAX_USERS = "max_users_returned";
protected static final String STEP_NOTIFY = "notify";
@@ -111,6 +119,9 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
/** True to allow duplicate authorities (with a different role) */
protected boolean allowDuplicateAuthorities = true;
/** Flag to determine if the maximum number of users have been returned */
protected boolean maxUsersReturned = false;
/** dialog state */
private String notify = NOTIFY_NO;
@@ -208,6 +219,7 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
{
super.init(parameters);
maxUsersReturned = false;
notify = NOTIFY_NO;
userRolesDataModel = null;
userGroupRoles = new ArrayList<UserGroupRole>(8);
@@ -339,6 +351,7 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
FacesContext context = FacesContext.getCurrentInstance();
SelectItem[] items;
this.maxUsersReturned = false;
UserTransaction tx = null;
try
@@ -360,11 +373,32 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
query.append("*\" @").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:userName:");
query.append(term);
query.append("*");
ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(
Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE,
query.toString());
List<NodeRef> nodes = resultSet.getNodeRefs();
int maxResults = Application.getClientConfig(context).getInviteUsersMaxResults();
if (logger.isDebugEnabled())
{
logger.debug("Maximum invite users results size: " + maxResults);
}
SearchParameters searchParams = new SearchParameters();
searchParams.addStore(Repository.getStoreRef());
searchParams.setLanguage(SearchService.LANGUAGE_LUCENE);
searchParams.setQuery(query.toString());
if (maxResults > 0)
{
searchParams.setLimit(maxResults);
searchParams.setLimitBy(LimitBy.FINAL_SIZE);
}
ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(searchParams);
List<NodeRef> nodes = resultSet.getNodeRefs();
// set the maximum users returned flag if appropriate
if (nodes.size() == maxResults)
{
this.maxUsersReturned = true;
}
for (int index=0; index<nodes.size(); index++)
{
@@ -403,6 +437,15 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
// commit the transaction
tx.commit();
}
catch (BooleanQuery.TooManyClauses clauses)
{
Utils.addErrorMessage(Application.getMessage(
FacesContext.getCurrentInstance(), "too_many_users"));
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
items = new SelectItem[0];
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
@@ -662,6 +705,28 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean
new String[] {buf.toString()});
}
/**
* @return flag to indicate whether maximum users have been returned
*/
public boolean getHaveMaximumUsersBeenReturned()
{
return this.maxUsersReturned;
}
/**
* @return Message to display when the maximum number of users have been returned
*/
public String getMaximumUsersMsg()
{
FacesContext context = FacesContext.getCurrentInstance();
String pattern = Application.getMessage(context, MSG_MAX_USERS);
String msg = MessageFormat.format(pattern,
Application.getClientConfig(context).getInviteUsersMaxResults());
return Utils.encode(msg);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
in.defaultReadObject();

View File

@@ -64,6 +64,7 @@ public class ClientConfigElement extends ConfigElementAdapter
private boolean forceAndTerms = false;
private int searchMaxResults = -1;
private int selectorsSearchMaxResults = 500;
private int inviteUsersMaxResults = 500;
private String helpUrl = null;
private String editLinkType = "http";
private String homeSpacePermission = null;
@@ -185,6 +186,11 @@ public class ClientConfigElement extends ConfigElementAdapter
combinedElement.setSelectorsSearchMaxResults(newElement.getSelectorsSearchMaxResults());
}
if (newElement.getInviteUsersMaxResults() != combinedElement.getInviteUsersMaxResults())
{
combinedElement.setInviteUsersMaxResults(newElement.getInviteUsersMaxResults());
}
if (newElement.isShelfVisible() != combinedElement.isShelfVisible())
{
combinedElement.setShelfVisible(newElement.isShelfVisible());
@@ -474,6 +480,29 @@ public class ClientConfigElement extends ConfigElementAdapter
{
this.selectorsSearchMaxResults = selectorsSearchMaxResults;
}
/**
* If positive, this will limit the size of the result set from the
* invite users wizard.
*
* @return The maximum number of results to display
*/
public int getInviteUsersMaxResults()
{
return this.inviteUsersMaxResults;
}
/**
* Set if the the result set from a search for the invite users wizard
* will be of limited size. If negative it is unlimited, by default,
* this is set to 500.
*
* @param inviteUsersMaxResults
*/
/*package*/ void setInviteUsersMaxResults(int inviteUsersMaxResults)
{
this.inviteUsersMaxResults = inviteUsersMaxResults;
}
/**
* @return Returns the default Home Space permissions.

View File

@@ -50,6 +50,7 @@ public class ClientElementReader implements ConfigElementReader
public static final String ELEMENT_SEARCHANDTERMS = "search-and-terms";
public static final String ELEMENT_SEARCHMAXRESULTS = "search-max-results";
public static final String ELEMENT_SELECTORSSEARCHMAXRESULTS = "selectors-search-max-results";
public static final String ELEMENT_INVITESEARCHMAXRESULTS = "invite-users-max-results";
public static final String ELEMENT_HOMESPACEPERMISSION = "home-space-permission";
public static final String ELEMENT_FROMEMAILADDRESS = "from-email-address";
public static final String ELEMENT_SHELFVISIBLE = "shelf-visible";
@@ -143,6 +144,14 @@ public class ClientElementReader implements ConfigElementReader
Integer.parseInt(selectorsSearchMaxResults.getTextTrim()));
}
// get the invite users max results size
Element inviteUsersMaxResults = element.element(ELEMENT_INVITESEARCHMAXRESULTS);
if (inviteUsersMaxResults != null)
{
configElement.setInviteUsersMaxResults(
Integer.parseInt(inviteUsersMaxResults.getTextTrim()));
}
// get the default permission for newly created users Home Spaces
Element permission = element.element(ELEMENT_HOMESPACEPERMISSION);
if (permission != null)

View File

@@ -29,6 +29,20 @@
<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %>
<%@ page import="org.alfresco.web.ui.common.Utils" %>
<h:panelGroup rendered="#{WizardManager.bean.haveMaximumUsersBeenReturned}">
<f:verbatim>
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc"); %>
<img src='<%=request.getContextPath()%>/images/icons/info_icon.gif' align='absmiddle' />&nbsp;&nbsp;
</f:verbatim>
<h:outputText id="infoMsg" value="#{WizardManager.bean.maximumUsersMsg}" />
<f:verbatim>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner");
out.write("<div style='padding:2px;'></div>"); %>
</f:verbatim>
</h:panelGroup>
<h:panelGrid columns="1" cellpadding="2" style="padding-top:2px; padding-bottom:2px;" width="100%">
<h:outputText styleClass="mainSubText" value="#{msg.specify_usersgroups}" />