Example #1
0
        public async Task <List <BlobStorageItemDto> > GetFileListAsync(int datasetId, string clientIp, CancellationToken cancellationToken = default)
        {
            try
            {
                if (await _studySpecificDatasetModelService.IsStudySpecific(datasetId))
                {
                    var dataset = await _studySpecificDatasetModelService.GetForResourceAndFirewall(datasetId, UserOperation.Study_Read);

                    var datasetResourceEntry = DatasetUtils.GetStudySpecificStorageAccountResourceEntry(dataset);

                    if (datasetResourceEntry == null)
                    {
                        throw new Exception($"Resource entry for Dataset {dataset.Id} not found");
                    }

                    var study = DatasetUtils.GetStudyFromStudySpecificDatasetOrThrow(dataset);

                    await _datasetCloudResourceService.EnsureFirewallExistsAsync(study, dataset, clientIp, cancellationToken);

                    _storageService.SetConnectionParameters(datasetResourceEntry.ResourceGroupName, datasetResourceEntry.ResourceName);
                }
                else
                {
                    throw new NotImplementedException("Only Study specific datasets is supported");
                }

                return(await _storageService.GetFileList(DatasetConstants.STUDY_SPECIFIC_DATASET_DEFAULT_CONTAINER, cancellationToken));
            }
            catch (Exception ex)
            {
                throw new Exception($"Unable to get file list from Storage Account - {ex.Message}", ex);
            }
        }