Source:
private Optional<List<Request>> createRequests(List<QuotaConsumptionParameter> parameters, CommandBase<?> command, boolean hardEnforcement, Pair<AuditLogType, AuditLogableBase> auditLogPair) { Map<Pair<Guid, Guid>, ClusterRequest> clusterRequests = new HashMap<>(); Map<Pair<Guid, Guid>, StorageRequest> storageRequests = new HashMap<>(); for (QuotaConsumptionParameter param: parameters) { if(Guid.isNullOrEmpty(param.getQuotaGuid())) { param.setQuotaGuid(storagePoolDefaultQuotaIdMap.get(command.getStoragePoolId())); } Quota quota = fetchQuotaFromCache(param.getQuotaGuid(), command.getStoragePoolId()); if (quota == null) { log.error("The quota id '{}' is not found in backend and DB.", param.getQuotaGuid()); if (hardEnforcement) { command.getReturnValue().getValidationMessages().add( EngineMessage.ACTION_TYPE_FAILED_QUOTA_IS_NO_LONGER_AVAILABLE_IN_SYSTEM.toString()); command.getReturnValue().getValidationMessages().add( String.format("$VmName %1$s", command.getVmName())); return Optional.empty(); } auditLogPair.setFirst(param.getParameterType() == QuotaConsumptionParameter.ParameterType.STORAGE ? AuditLogType.MISSING_QUOTA_STORAGE_PARAMETERS_PERMISSIVE_MODE : AuditLogType.MISSING_QUOTA_CLUSTER_PARAMETERS_PERMISSIVE_MODE); continue; } ValidationResult validation = ValidationResult.VALID; if (param instanceof QuotaClusterConsumptionParameter) { validation = validateAndAddToClusterRequests((QuotaClusterConsumptionParameter) param, quota, command.getClass().getName(), clusterRequests); } if (param instanceof QuotaStorageConsumptionParameter) { validation = validateAndAddToStorageRequests((QuotaStorageConsumptionParameter) param, quota, command.getClass().getName(), storageRequests); } if (!validation.isValid() && hardEnforcement) { command.getReturnValue().getValidationMessages().addAll(validation.getMessagesAsStrings()); return Optional.empty(); } } List<Request> result = new ArrayList<>(clusterRequests.values()); result.addAll(storageRequests.values()); return Optional.of(result); }

Target:
private Optional<List<Request>> createRequests(List<QuotaConsumptionParameter> parameters, CommandBase<?> command, boolean hardEnforcement, Pair<AuditLogType, AuditLogableBase> auditLogPair) { Map<Pair<Guid, Guid>, ClusterRequest> clusterRequests = new HashMap<>(); Map<Pair<Guid, Guid>, StorageRequest> storageRequests = new HashMap<>(); for (QuotaConsumptionParameter param: parameters) { if(Guid.isNullOrEmpty(param.getQuotaGuid())) { param.setQuotaGuid(storagePoolDefaultQuotaIdMap.get(command.getStoragePoolId())); } Quota quota = fetchQuotaFromCache(param.getQuotaGuid(), command.getStoragePoolId()); if (quota == null) { log.error("The quota id '{}' is not found in backend and DB.", param.getQuotaGuid()); if (hardEnforcement) { command.getReturnValue().getValidationMessages().add( EngineMessage.ACTION_TYPE_FAILED_QUOTA_IS_NO_LONGER_AVAILABLE_IN_SYSTEM.toString()); command.getReturnValue().getValidationMessages().add( String.format("$VmName %1$s", command.getVmName())); return Optional.empty(); } auditLogPair.setFirst(param.getParameterType() == QuotaConsumptionParameter.ParameterType.STORAGE ? AuditLogType.MISSING_QUOTA_STORAGE_PARAMETERS_PERMISSIVE_MODE : AuditLogType.MISSING_QUOTA_CLUSTER_PARAMETERS_PERMISSIVE_MODE); continue; } ValidationResult validation = ValidationResult.VALID; if (param instanceof QuotaClusterConsumptionParameter) { validation = validateAndAddToClusterRequests((QuotaClusterConsumptionParameter) param, quota, command.getClass().getName(), clusterRequests); } else if (param instanceof QuotaStorageConsumptionParameter) { validation = validateAndAddToStorageRequests((QuotaStorageConsumptionParameter) param, quota, command.getClass().getName(), storageRequests); } if (!validation.isValid() && hardEnforcement) { command.getReturnValue().getValidationMessages().addAll(validation.getMessagesAsStrings()); return Optional.empty(); } } List<Request> result = new ArrayList<>(clusterRequests.values()); result.addAll(storageRequests.values()); return Optional.of(result); }