Source:
protected boolean validate() { StorageServerConnections paramConnection = getConnection(); if (StringUtils.isNotEmpty(paramConnection.getId())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY); } if (!isValidConnection(paramConnection)) { return false; } Guid storagePoolId = Guid.isNullOrEmpty(getParameters().getVdsId()) ? null : getVds().getStoragePoolId(); if (isConnWithSameDetailsExists(paramConnection, storagePoolId)) { List<StorageServerConnections> storageServerConnections = null; String storageId = ""; String storageDomainName = ""; storageServerConnections = getConnWithSameDetailsExists(paramConnection, storagePoolId); if (storageServerConnections != null && storageServerConnections.size() > 0 ) { storageId = storageServerConnections.get(0).getId(); } if (getStorageDomainsByConnId(storageId) != null && getStorageDomainsByConnId(storageId).size() > 0) { if ( getStorageDomainsByConnId(storageId).get(0).getStorageStaticData() != null ) { storageDomainName = getStorageDomainsByConnId(storageId).get(0).getStorageStaticData().getName(); } } addValidationMessageVariable("storage", storageId); addValidationMessageVariable("storageDomainName", storageDomainName); return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS_INFO); } if (!Guid.isNullOrEmpty(getParameters().getVdsId())) { if (getVds() == null) { return failValidation(EngineMessage.VDS_INVALID_SERVER_ID); } if (getVds().getStatus() != VDSStatus.Up) { return failValidation(EngineMessage.VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP); } } return true; }

Target:
protected boolean validate() { List<StorageServerConnections> storageServerConnections = null; StorageServerConnections paramConnection = getConnection(); if (StringUtils.isNotEmpty(paramConnection.getId())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY); } if (!isValidConnection(paramConnection)) { return false; } Guid storagePoolId = Guid.isNullOrEmpty(getParameters().getVdsId()) ? null : getVds().getStoragePoolId(); storageServerConnections = getConnWithSameDetailsExists(paramConnection, storagePoolId); if (isConnWithSameDetailsExists(paramConnection, storageServerConnections)) { String storageId = "", storageDomainName = ""; if (storageServerConnections != null && storageServerConnections.size() > 0) { storageId = storageServerConnections.get(0).getId(); } List<StorageDomain> storageDomainsByConnId = getStorageDomainsByConnId(storageId); if (storageDomainsByConnId != null && storageDomainsByConnId.size() > 0) { if (storageDomainsByConnId.get(0).getStorageStaticData() != null) { storageDomainName = storageDomainsByConnId.get(0).getStorageStaticData().getName(); } } addValidationMessageVariable("storage", storageId); addValidationMessageVariable("storageDomainName", storageDomainName); return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS); } if (!Guid.isNullOrEmpty(getParameters().getVdsId())) { if (getVds() == null) { return failValidation(EngineMessage.VDS_INVALID_SERVER_ID); } if (getVds().getStatus() != VDSStatus.Up) { return failValidation(EngineMessage.VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP); } } return true; }