Source:
public static void reduceCommandStorageSize(Guid storageDomainId, Long subtractedSize, QuotaEnforcmentTypeEnum quotaEnforcedType, Guid commandId, Guid quotaId) { if (!validateReduceQuotaParameters(storageDomainId, quotaEnforcedType, commandId, quotaId)) { return; } if (subtractedSize == null || subtractedSize.longValue() == 0) { log.errorFormat("Sutracted size is not valid, quota delta will not be reduced."); return; } QuotaStorage quotaStorage = getQuotaStorageForStorageDomainId(quotaId, storageDomainId); getLockForQuotaId(quotaId).lock(); try { Map<Guid, QuotaDeltaValue> quotaDeltaMap = commandDeltaMap.get(quotaStorage.getQuotaStorageId()); if (quotaDeltaMap == null) { log.errorFormat("Quota id {0} for storage domain id {1} has no associated command map", quotaId, storageDomainId); } else if (quotaDeltaMap.get(commandId) == null) { log.errorFormat("Quota id {0} for storage domain id {1} and command id (2) has no associated delta quota", quotaId, storageDomainId, commandId); } else { QuotaDeltaValue quotaDeltaValue = quotaDeltaMap.get(commandId); Double storageSize = quotaDeltaValue.getStorageSizeToBeUsed(); if (storageSize == null) { log.errorFormat("Quota id {0} for storage domain id {1} and command id (2) does not have storage delta size", quotaId, storageDomainId, commandId); } else if (storageSize < subtractedSize) { log.errorFormat("Quota id {0} for storage domain id {1} and command id (2) has less storage delta size from the size requested to be reduced. The delta value will be se to 0", quotaId, storageDomainId, commandId); quotaDeltaValue.setStorageSizeToBeUsed(0d); } else { quotaDeltaValue.setStorageSizeToBeUsed(quotaDeltaValue.getStorageSizeToBeUsed() - subtractedSize); } } } finally { getLockForQuotaId(quotaId).unlock(); } }

Target:
public static void reduceCommandStorageSize(Guid storageDomainId, Long subtractedSize, QuotaEnforcmentTypeEnum quotaEnforcedType, Guid commandId, Guid quotaId) { if (!validateReduceQuotaParameters(storageDomainId, quotaEnforcedType, commandId, quotaId)) { return; } if (subtractedSize == null || subtractedSize.longValue() == 0) { log.errorFormat("Subtracted size is not valid, quota delta will not be reduced for qutoa Id {0} and storage domain Id {1}.", quotaId, storageDomainId); return; } QuotaStorage quotaStorage = getQuotaStorageForStorageDomainId(quotaId, storageDomainId); getLockForQuotaId(quotaId).lock(); try { Map<Guid, QuotaDeltaValue> quotaDeltaMap = commandDeltaMap.get(quotaStorage.getQuotaStorageId()); if (quotaDeltaMap == null) { log.errorFormat("Quota id {0} for storage domain id {1} has no associated command map", quotaId, storageDomainId); } else if (quotaDeltaMap.get(commandId) == null) { log.errorFormat("Quota id {0} for storage domain id {1} and command id (2) has no associated delta quota", quotaId, storageDomainId, commandId); } else { QuotaDeltaValue quotaDeltaValue = quotaDeltaMap.get(commandId); Double storageSize = quotaDeltaValue.getStorageSizeToBeUsed(); if (storageSize == null) { log.errorFormat("Quota id {0} for storage domain id {1} and command id (2) does not have storage delta size", quotaId, storageDomainId, commandId); } else if (storageSize < subtractedSize) { log.errorFormat("Quota id {0} for storage domain id {1} and command id (2) has less storage delta size from the size requested to be reduced. The delta value will be se to 0", quotaId, storageDomainId, commandId); quotaDeltaValue.setStorageSizeToBeUsed(0d); } else { quotaDeltaValue.setStorageSizeToBeUsed(quotaDeltaValue.getStorageSizeToBeUsed() - subtractedSize); } } } finally { getLockForQuotaId(quotaId).unlock(); } }