/** * Find the "best" access in case theres more than one, based on what the CDM knows how to open * and use. * * @param accessList choose from this list. * @return best access method. */ public InvAccess chooseDatasetAccess(List<InvAccess> accessList) { if (accessList.size() == 0) return null; InvAccess access = null; if (preferCdm) access = findAccessByServiceType(accessList, ServiceType.CdmRemote); if (access == null) access = findAccessByServiceType( accessList, ServiceType.FILE); // should mean that it can be opened through netcdf API if (access == null) access = findAccessByServiceType( accessList, ServiceType.NETCDF); // ServiceType.NETCDF is deprecated, use FILE if (access == null) access = findAccessByServiceType(accessList, ServiceType.DODS); if (access == null) access = findAccessByServiceType(accessList, ServiceType.OPENDAP); if (access == null) access = findAccessByServiceType(accessList, ServiceType.CdmRemote); // look for HTTP with format we can read if (access == null) { InvAccess tryAccess = findAccessByServiceType(accessList, ServiceType.HTTPServer); if (tryAccess == null) tryAccess = findAccessByServiceType( accessList, ServiceType.HTTP); // ServiceType.HTTP should be HTTPServer if (tryAccess != null) { DataFormatType format = tryAccess.getDataFormatType(); // these are the file types we can read if ((DataFormatType.BUFR == format) || (DataFormatType.GINI == format) || (DataFormatType.GRIB1 == format) || (DataFormatType.GRIB2 == format) || (DataFormatType.HDF5 == format) || (DataFormatType.NCML == format) || (DataFormatType.NETCDF == format) || (DataFormatType.NEXRAD2 == format) || (DataFormatType.NIDS == format)) access = tryAccess; } } // ADDE if (access == null) access = findAccessByServiceType(accessList, ServiceType.ADDE); // RESOLVER if (access == null) { access = findAccessByServiceType(accessList, ServiceType.RESOLVER); } return access; }
private InvAccess findAccessByDataFormatType(List<InvAccess> accessList, DataFormatType type) { for (InvAccess a : accessList) { if (type.toString().equalsIgnoreCase(a.getDataFormatType().toString())) return a; } return null; }