class FtpRetriever implements ImageRetrieverInterface {

    @Override
    public void setupDataRetrieval(Map<String, ?> dataSourceConfig, ObjectRecognitionCore source) throws Exception {
        log = LoggerFactory.getLogger(this.getClass().getCanonicalName() + "#" + source.getSourceName());
        
        // Return and don't save values if the config doesn't want a default
        if (dataSourceConfig.get(NO_DEFAULT) instanceof Boolean && (Boolean) dataSourceConfig.get(NO_DEFAULT)) {
            noDefault = true;
            return;
        }
        
        // Get the domain name to connect to
        if (dataSourceConfig.get(SERVER) instanceof String) {
            server = obtainDomainName((String) dataSourceConfig.get(SERVER));
        } else {
            throw new Exception(this.getClass().getCanonicalName() + ".noServerSpecified: "
                    + "No server was specified in the configuration setup." );
        }
        
        // Setup for FTP/FTPS/SFTP based on the config. Default to FTP
        if (dataSourceConfig.get(CON_TYPE) instanceof String) {
            String type = (String) dataSourceConfig.get(CON_TYPE);
            if (type.equalsIgnoreCase(FTPS)) {
                conType = FTPS;
                // FTPS has a few more options available
                if (dataSourceConfig.get(IMPLICIT) instanceof Boolean && (Boolean) dataSourceConfig.get(IMPLICIT)) {
                    isImplicit = true;
                }
                if (dataSourceConfig.get(PROTOCOL) instanceof String) {
                    protocol = (String) dataSourceConfig.get(PROTOCOL);
                }
            } else if (type.equalsIgnoreCase(SFTP)) {
                conType = SFTP;
            } else if (!type.equalsIgnoreCase(FTP)) {
                log.warn("Unexpected value of 'conType'. Should be 'ftps', 'sftp', or 'ftp'. Defaulting to 'ftp'");
            }
        }
        
        // Obtain the username and password
        if (dataSourceConfig.get(USERNAME) instanceof String) {
            username = (String) dataSourceConfig.get(USERNAME);
        } else {
            throw new Exception(this.getClass().getCanonicalName() + ".noUsername: "
                    + "No username was given in the configuration setup");
        }
        if (dataSourceConfig.get(PASSWORD) instanceof String) {
            password = (String) dataSourceConfig.get("password");
        } else {
            throw new Exception(this.getClass().getCanonicalName() + ".noPassword: "
                    + "No password was given in the configuration setup");
        }
        
        // Connect to the file server using the requested connection type
        if (conType == FTP || conType == FTPS) { 
            try {
                ftpClient = connectToFtpServer(server, username, password, conType, protocol, isImplicit);
            } catch (Exception e) {
                // Use the base message of the exception thrown, but add the error-specifier 
                throw new Exception(this.getClass().getCanonicalName() + "." + e.getMessage()
                , e);
            }
        } else {
            try {
                session = connectToSftpServer(server, username, password);
            } catch (Exception e) {
                // Use the base message of the exception thrown, but add the error-specifier 
                throw new Exception(this.getClass().getCanonicalName() + "." + e.getMessage()
                , e);
            }
        }
    }

}