Fabio Sinibaldi 2016-09-12 10:55:51 +00:00
parent d46e112929
commit 7198dfa329
1 changed files with 9 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import org.gcube.data.transfer.library.faults.InvalidDestinationException;
import org.gcube.data.transfer.library.faults.InvalidSourceException; import org.gcube.data.transfer.library.faults.InvalidSourceException;
import org.gcube.data.transfer.library.faults.RemoteServiceException; import org.gcube.data.transfer.library.faults.RemoteServiceException;
import org.gcube.data.transfer.library.faults.SourceNotSetException; import org.gcube.data.transfer.library.faults.SourceNotSetException;
import org.gcube.data.transfer.library.faults.UnreachableNodeException;
import org.gcube.data.transfer.library.model.LocalSource; import org.gcube.data.transfer.library.model.LocalSource;
import org.gcube.data.transfer.library.model.Source; import org.gcube.data.transfer.library.model.Source;
import org.gcube.data.transfer.library.model.StorageSource; import org.gcube.data.transfer.library.model.StorageSource;
@ -121,9 +122,13 @@ public abstract class Transferer {
} }
} }
protected void checkDestination() throws InvalidDestinationException,DestinationNotSetException{ protected void checkDestination() throws InvalidDestinationException,DestinationNotSetException, UnreachableNodeException{
if(destination==null) throw new DestinationNotSetException(); if(destination==null) throw new DestinationNotSetException();
// perform checks if(!destination.getPersistenceId().equals(Destination.DEFAULT_PERSISTENCE_ID)){
Set<String> availablePersistenceIds=getDestinationCapabilities().getAvailablePersistenceIds();
if(!availablePersistenceIds.contains(destination.getPersistenceId()))
throw new InvalidDestinationException("Declared persistence id "+destination.getPersistenceId()+" not found. Available are "+availablePersistenceIds);
}
} }
protected void checkSource() throws SourceNotSetException, InvalidSourceException{ protected void checkSource() throws SourceNotSetException, InvalidSourceException{
@ -145,11 +150,11 @@ public abstract class Transferer {
} }
public TransferCapabilities getDestinationCapabilities() throws InitializationException { public TransferCapabilities getDestinationCapabilities() throws UnreachableNodeException {
try{ try{
return client.getCapabilties(); return client.getCapabilties();
}catch(Exception e){ }catch(Exception e){
throw new InitializationException(e); throw new UnreachableNodeException(e);
} }
} }