mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
DM User Usages/Quotas - fixes to prevent negative quota and to allow editing to be finished after an error
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8020 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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
|
||||
|
@@ -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,9 +800,17 @@ 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));
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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<Node> 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<Node> 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user