@@ -0,0 +1,2538 @@
+package org.ovirt.engine.core.bll;%0A%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport org.ovirt.engine.core.common.VdcObjectType;%0Aimport org.ovirt.engine.core.common.action.QuotaCRUDParameters;%0Aimport org.ovirt.engine.core.common.businessentities.Quota;%0Aimport org.ovirt.engine.core.common.businessentities.QuotaEnforcmentTypeEnum;%0Aimport org.ovirt.engine.core.compat.Guid;%0Aimport org.ovirt.engine.core.dal.VdcBllMessages;%0A%0Apublic class RemoveQuotaCommand%3CT extends QuotaCRUDParameters%3E extends CommandBase%3CT%3E %7B%0A%0A    /**%0A     * Generated serialization UUID.%0A     */%0A    private static final long serialVersionUID = 8037593564997497667L;%0A%0A    public RemoveQuotaCommand(T parameters) %7B%0A        super(parameters);%0A        setQuotaId(getParameters().getQuotaId());%0A    %7D%0A%0A    @Override%0A    protected boolean canDoAction() %7B%0A        if (getParameters() == null %7C%7C (getParameters().getQuotaId() == null)) %7B%0A            addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_NOT_EXIST);%0A        %7D%0A%0A        Quota quota = getQuota();%0A        if (quota == null) %7B%0A            addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_NOT_EXIST);%0A            return false;%0A        %7D%0A%0A        // Check if there is attempt to delete the default quota while storage pool enforcement type is disabled.%0A        if (getStoragePoolDAO().get(quota.getStoragePoolId()).getQuotaEnforcementType() == QuotaEnforcmentTypeEnum.DISABLED && quota.getIsDefaultQuota()) %7B%0A            addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_CAN_NOT_HAVE_DEFAULT_INDICATION);%0A        %7D%0A%0A        // Check If we try to delete the last quota in the DC.%0A        List%3CQuota%3E quotaList = getQuotaDAO().getQuotaByStoragePoolGuid(getParameters().getStoragePoolId());%0A        if (quotaList.size() %3C= 1) %7B%0A            addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DATA_CENTER_MUST_HAVE_AT_LEAST_ONE_QUOTA);%0A        %7D%0A        return true;%0A    %7D%0A%0A    @Override%0A    protected void executeCommand() %7B%0A        getQuotaDAO().remove(getParameters().getQuotaId());%0A        getReturnValue().setSucceeded(true);%0A    %7D%0A%0A    @Override%0A    public Map%3CGuid, VdcObjectType%3E getPermissionCheckSubjects() %7B%0A        return Collections.singletonMap(getQuotaId() == null ? null : getQuotaId().getValue(),%0A                VdcObjectType.Quota);%0A    %7D%0A%0A    protected void setActionMessageParameters() %7B%0A        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE);%0A        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__QUOTA);%0A    %7D%0A%7D%0A

Remove quota command