Source:
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 = null; oldConnection = getStorageConnDao().get(connectionId); if (oldConnection == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST); } List<StorageServerConnections> connections = getStorageConnDao().getAllForStorage(newConnectionDetails.getconnection()); if (connections != null) { if (connections.size() > 1) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS); } else if (connections.size() == 1 && !connections.get(0).getid().equals(oldConnection.getid())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS); } } List<StorageDomain> domains = getStorageDomainsByConnId(newConnectionDetails.getid()); if (domains != null) { if (domains.size() != 1) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS); } setStorageDomain(domains.get(0)); if (!isNfsPathEditable(getStorageDomain())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE); } } return super.canDoAction(); }

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(); 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()); if (domains.size() != 1) { 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(); }