diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 352496c3e1..0a2d687628 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -1765,6 +1765,7 @@ error_restore_search=Failed to restore saved search due to error: {0} error_shortcut_permissions=Unable to navigate to the item as it cannot be read by this user. Another user may have modified the permission. error_association=Failed to find association definition for association \"{0}\". error_charset_null=Null characterset value +error_negative_quota=Quota cannot be negative: {0} # Confirmations return_to_application=Return to application diff --git a/source/java/org/alfresco/web/bean/users/CreateUserWizard.java b/source/java/org/alfresco/web/bean/users/CreateUserWizard.java index 9237ffa493..5a65dfab77 100644 --- a/source/java/org/alfresco/web/bean/users/CreateUserWizard.java +++ b/source/java/org/alfresco/web/bean/users/CreateUserWizard.java @@ -758,12 +758,20 @@ public class CreateUserWizard extends BaseWizardBean if (logger.isDebugEnabled()) logger.debug("Created User Authentication instance for username: " + this.userName); - putSizeQuotaProperty(this.userName, this.sizeQuota, this.sizeQuotaUnits); + if ((this.sizeQuota != null) && (this.sizeQuota < 0L)) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, UsersDialog.ERROR_NEGATIVE_QUOTA), this.sizeQuota)); + outcome = null; + } + else + { + putSizeQuotaProperty(this.userName, this.sizeQuota, this.sizeQuotaUnits); + } } else { - outcome = null; Utils.addErrorMessage(Application.getMessage(context, UsersDialog.ERROR_PASSWORD_MATCH)); + outcome = null; } invalidateUserList(); } @@ -792,11 +800,19 @@ public class CreateUserWizard extends BaseWizardBean protected void putSizeQuotaProperty(String userName, Long quota, String quotaUnits) { - if ((quota != null) && (quota > 0)) + if (quota != null) { - quota = convertToBytes(quota, quotaUnits); + if (quota >= 0L) + { + quota = convertToBytes(quota, quotaUnits); + } + else + { + // ignore negative quota + return; + } } - + this.contentUsageService.setUserQuota(userName, (quota == null ? -1 : quota)); } diff --git a/source/java/org/alfresco/web/bean/users/EditUserWizard.java b/source/java/org/alfresco/web/bean/users/EditUserWizard.java index d2d6f72b81..6c20e67bc5 100644 --- a/source/java/org/alfresco/web/bean/users/EditUserWizard.java +++ b/source/java/org/alfresco/web/bean/users/EditUserWizard.java @@ -205,14 +205,26 @@ public class EditUserWizard extends CreateUserWizard // TODO: RESET HomeSpace Ref found in top-level navigation bar! // NOTE: not need cos only admin can do this? - putSizeQuotaProperty(this.userName, this.sizeQuota, this.sizeQuotaUnits); - + if ((this.sizeQuota != null) && (this.sizeQuota < 0L)) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, UsersDialog.ERROR_NEGATIVE_QUOTA), this.sizeQuota)); + outcome = null; + } + else + { + putSizeQuotaProperty(this.userName, this.sizeQuota, this.sizeQuotaUnits); + } } catch (Throwable e) { Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e); outcome = null; } + + if (outcome == null) { + this.isFinished = false; + } + return outcome; } } diff --git a/source/java/org/alfresco/web/bean/users/UsersDialog.java b/source/java/org/alfresco/web/bean/users/UsersDialog.java index f3996a0b81..baeb34734d 100644 --- a/source/java/org/alfresco/web/bean/users/UsersDialog.java +++ b/source/java/org/alfresco/web/bean/users/UsersDialog.java @@ -71,6 +71,7 @@ public class UsersDialog extends BaseDialogBean implements IContextListener, Cha public static String BEAN_NAME = "UsersDialog"; public static final String ERROR_PASSWORD_MATCH = "error_password_match"; + public static final String ERROR_NEGATIVE_QUOTA = "error_negative_quota"; private static final String ERROR_DELETE = "error_delete_user"; private static final String ERROR_USER_DELETE = "error_delete_user_object"; @@ -128,30 +129,32 @@ public class UsersDialog extends BaseDialogBean implements IContextListener, Cha return getUsers().size(); } - public long getUsersTotalUsage() + public Long getUsersTotalUsage() { - long totalUsage = 0L; + Long totalUsage = null; List users = getUsers(); for(Node user : users) { Long sizeLatest = (Long)properties.getUserUsage((String)user.getProperties().get("userName")); - if (sizeLatest != null) + if ((sizeLatest != null) && (sizeLatest != -1L)) { + if (totalUsage == null) { totalUsage = 0L; } totalUsage += sizeLatest; } } return totalUsage; } - public long getUsersTotalQuota() + public Long getUsersTotalQuota() { - long totalQuota = 0L; + Long totalQuota = null; List users = getUsers(); for(Node user : users) { Long sizeCurrent = (Long)user.getProperties().get("sizeQuota"); - if (sizeCurrent != null) + if ((sizeCurrent != null) && (sizeCurrent != -1L)) { + if (totalQuota == null) { totalQuota = 0L; } totalQuota += sizeCurrent; } }