Source:
<code>protected boolean canDoAction() { StorageServerConnections newConnectionDetails = getParameters().getStorageServerConnection(); if (newConnectionDetails.getstorage_type() != StorageType.NFS) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE); } if (!new NfsMountPointConstraint().isValid(newConnectionDetails.getconnection(), null)) { return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_INVALID); } String connectionId = newConnectionDetails.getid(); oldConnection = getStorageConnDao().get(connectionId); if (oldConnection == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST); } if(!newConnectionDetails.getstorage_type().equals(oldConnection.getstorage_type())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE); } if (!oldConnection.getconnection().equals(newConnectionDetails.getconnection())) { List<StorageServerConnections> connections = getStorageConnDao().getAllForStorage(newConnectionDetails.getconnection()); if (!connections.isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS); } } List<StorageDomain> domains = getStorageDomainsByConnId(newConnectionDetails.getid()); <START> if (domains.size() != 1) { <END> String domainNames = createDomainNamesList(domains); addCanDoActionMessage(String.format("$domainNames %1$s", domainNames)); return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS); } setStorageDomain(domains.get(0)); if (!isConnectionEditable(getStorageDomain())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE); } return super.canDoAction(); }</code><technical_language>1. if storage domains connection? (I'm assuming this is rest api?) 2. block domains this problematic cases multiple domains for connection</technical_language>

Target:
protected boolean canDoAction() { StorageServerConnections newConnectionDetails = getParameters().getStorageServerConnection(); if (newConnectionDetails.getstorage_type() != StorageType.NFS) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE); } if (!new NfsMountPointConstraint().isValid(newConnectionDetails.getconnection(), null)) { return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_INVALID); } String connectionId = newConnectionDetails.getid(); StorageServerConnections oldConnection = getStorageConnDao().get(connectionId); if (oldConnection == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST); } if(!newConnectionDetails.getstorage_type().equals(oldConnection.getstorage_type())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE); } if (!oldConnection.getconnection().equals(newConnectionDetails.getconnection())) { List<StorageServerConnections> connections = getStorageConnDao().getAllForStorage(newConnectionDetails.getconnection()); if (!connections.isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS); } } if(domains == null) { domains = getStorageDomainsByConnId(newConnectionDetails.getid()); } if(domains.isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST); } else if(domains.size() == 1) { setStorageDomain(domains.get(0)); } else { String domainNames = createDomainNamesList(domains); addCanDoActionMessage(String.format("$domainNames %1$s", domainNames)); return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS); } if (!isConnectionEditable(getStorageDomain())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE); } return super.canDoAction(); }