in code/OBADownload/Components/DownloadRegionsList.cs [27:75]
public static async Task<RegionsList> DownloadAndStore(Client obaClient, StorageManager downloadStorage, StorageManager downloadMetadataStorage, string runId)
{
// check inputs
if (obaClient == null)
{
throw new ArgumentNullException("obaClient");
}
else if (downloadStorage == null)
{
throw new ArgumentNullException("downloadStorage");
}
else if (downloadMetadataStorage == null)
{
throw new ArgumentNullException("downloadMetadataStorage");
}
else if (string.IsNullOrWhiteSpace(runId))
{
throw new ArgumentNullException("runId");
}
// fetch the regions list
RegionsList regionsList = await obaClient.GetAllRegionsAsync();
// check the regions list
if (regionsList == null)
{
throw new Exception("regions list is null");
}
else if (regionsList.Regions == null)
{
throw new Exception("regions in regions list is null");
}
else if (regionsList.Regions.Count <= 0)
{
throw new Exception("regions in regions list is empty");
}
else if (string.IsNullOrWhiteSpace(regionsList.RegionsRawContent))
{
throw new Exception("raw content in regions list is empty");
}
// store it
await downloadStorage.RegionsListStore.Insert(regionsList);
// add a metadata entry
await downloadMetadataStorage.DownloadMetadataStore.Insert(runId, string.Empty, string.Empty, RecordType.RegionsList, 1);
return regionsList;
}