Exemplo n.º 1
0
        public async override Task <TranscriptSet> QueryOneAsync(FileIdentifier identifier, CancellationToken cancellationToken = default(CancellationToken))
        {
            var rootFile = await Connection.File.GetAsync(identifier);

            var transcriptJson =
                rootFile.Read <List <AlternativeView> >(MetadataKeyConstants.ALTERNATIVE_VIEWS)
                .FirstOrDefault(v => v.Name == FILENAME_JSON);

            var set = await ViewSetService.LoadSet <TranscriptSet>(identifier);

            if (transcriptJson != null)
            {
                set.Segments = await Connection.File.DownloadAsAsync <List <SegmentModel> >(transcriptJson.FileIdentifier);
            }
            else
            {
                var vttIdentifier = set.Subtitles?.FirstOrDefault()?.FileIdentifier;
                set.Segments = await TranscriptService.LoadSegments(Connection, vttIdentifier);
            }

            return(set);
        }
Exemplo n.º 2
0
        public async Task <T> LoadSet <T>(FileIdentifier fileIdentifier)
            where T : BaseSet
        {
            var file = await api.File.GetAsync(fileIdentifier);

            var fileStatus = await api.File.GetOnlineStatusAsync(fileIdentifier);


            var organization = await api.Organization.GetAsync(fileIdentifier as OrganizationIdentifier);

            BaseSet set = null;

            // this is awful, but no clear security check to perform
            bool isPrivileged = !EDiscoveryUtility.IsUserEDiscovery(this.api.UserAccessIdentifiers) &&
                                !LEOUploadUtility.IsUserLeo(this.api.UserAccessIdentifiers);

            if (typeof(T).Equals(typeof(TextSet)))
            {
                set = TextService.TextSetGet(file, true);
            }

            if (typeof(T).Equals(typeof(DocumentSet)))
            {
                set = DocumentSetService.DocumentSetGet(file);
            }

            if (typeof(T).Equals(typeof(MediaSet)))
            {
                set = MediaService.MediaSetGet(organization, file, isPrivileged);
            }

            if (typeof(T).Equals(typeof(TranscriptSet)))
            {
                var transcriptSet = TranscriptService.TranscriptSetGet(organization, file);
                transcriptSet.Segments = await TranscriptService.LoadSegments(api, transcriptSet.Subtitles?.FirstOrDefault()?.FileIdentifier);

                set = transcriptSet;
            }

            if (typeof(T).Equals(typeof(ClipSet)))
            {
                var clipSet = ClipService.ClipSetGet(organization, file);
                set = clipSet;
            }

            if (typeof(T).Equals(typeof(ImageSet)))
            {
                set = ImageService.ImageSetGet(file);
            }

            if (typeof(T).Equals(typeof(UnknownSet)))
            {
                set = UnknownService.UnknownSetGet(file);
            }

            if (set.AllowedOperations == null)
            {
                set.AllowedOperations = new[]
                {
                    AllowedOperation.GetAllowedOperationDownload(fileIdentifier, false)
                }
            }
            ;

            set.RootFileIdentifier = file.Read(MetadataKeyConstants.CHILDOF, defaultValue: file.Identifier);

            if (set.RootFileIdentifier.Equals(fileIdentifier))
            {
                set.Views = DetectFileViews(organization, file);
            }
            else
            {
                set.Views = DetectFileViews(organization, await api.File.GetAsync(set.RootFileIdentifier));
            }


            // some wierd logic for eDiscovery
            // if eDiscovery, then no subtitles
            if (set is MediaSet && EDiscoveryUtility.IsUserEDiscovery(api.UserAccessIdentifiers))
            {
                var media = set as MediaSet;
                media.Subtitles = null;
            }


            if (fileStatus != FileModel.OnlineStatus.Online)
            {
                set.Views = new ManagerFileView[] { new ManagerFileView {
                                                        ViewerType = ManagerFileView.ViewerTypeEnum.Offline,
                                                        Identifier = set.RootFileIdentifier
                                                    } };

                set.AllowedOperations = new AllowedOperation[]
                {
                    AllowedOperation.GetAllowedOperationRequestOnlineFolder(set.RootFileIdentifier)
                };

                set.RootFileIdentifier = null;
            }

            return(set as T);
        }