예제 #1
0
        public async Task UnShareFileForEDiscoveryAsync(FileIdentifier fileIdentifier)
        {
            // We need to grab the details of the file first, so we can see what it's current state is.
            var file = await connection.File.GetAsync(fileIdentifier);

            var shareState = EDiscoveryUtility.GetCurrentShareState(file);

            // The only case where you can pull a file back from shared, is if it's been staged.  In which case you can move it back to not shared yet.
            // If the file hasn't been shared, or if it's moved fully to shared, then we're not going to do anything.
            if (shareState == EDiscoveryShareState.Staged)
            {
                UpdateShareState(file, EDiscoveryShareState.NotShared);
                await connection.File.PutAsync(file);
            }
        }
예제 #2
0
        protected override List <AllowedOperation> GetPageAllowedOperations(PathIdentifier identifier)
        {
            var ops = new List <AllowedOperation>();

            if (ManagerConfiguration.IsFeatureEnabledSearch)
            {
                ops.Add(AllowedOperation.GetAllowedOperationSearch(identifier));
            }

            var recipients = state.Folder.MetaEDiscoveryRecipientListRead();

            if (state.Folder.Files.Rows.Any(f => EDiscoveryUtility.GetCurrentShareState(f) == EDiscoveryShareState.Staged))
            {
                ops.Add(AllowedOperation.GetAllowedOperationPublish(identifier as FolderIdentifier, recipients.Count));
            }

            return(ops);
        }
예제 #3
0
        public async override Task <PathIdentifier> DeleteOneAsync(PathIdentifier identifier, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await OpenFolder(identifier, cancellationToken : cancellationToken);

            await state.Paths.Delete(identifier, async (doomedPath) =>
            {
                // find any files under the path to be deleted
                var doomedFiles = state.Folder?.Files.Rows.Where(f =>
                {
                    var filePathIdentifier = f.MetaPathIdentifierRead();
                    return((filePathIdentifier.Equals(doomedPath)) ||
                           (filePathIdentifier.IsChildOf(doomedPath)));
                }).ToList();

                // Before we go deleting anything we need to see if any of these files have been shared.
                // If they have been shared we're not going to allow them to be deleted.
                doomedFiles = doomedFiles.Where(f => EDiscoveryUtility.GetCurrentShareState(f) != EDiscoveryShareState.Published).ToList();

                foreach (var doomedFile in doomedFiles)
                {
                    await Connection.File.DeleteAsync(doomedFile.Identifier, cancellationToken: cancellationToken);

                    var doomedChildren = state.Folder.Files.Rows
                                         .Where(f => doomedFile.Identifier.Equals(f.MetaChildOfRead()))
                                         .ToList();

                    foreach (var childOfDoomed in doomedChildren)
                    {
                        await Connection.File.DeleteAsync(childOfDoomed.Identifier, cancellationToken: cancellationToken);
                    }
                }
            });

            // if we filtered any out above, write the new list back to the folder
            if (state.Paths.IsDirty)
            {
                state.Paths.Write(state.Folder);
                await Connection.Folder.PutAsync(state.Folder);
            }

            return(identifier);
        }
예제 #4
0
        public async Task <EDiscoveryStatisticsResponse> GetEDiscoveryStatistics(FolderIdentifier folderIdentifier)
        {
            var stats = new EDiscoveryStatisticsResponse();

            // Setup our state so we have everything we need.
            var folder = await connection.Folder.GetAsync(folderIdentifier, new List <PopulationDirective>
            {
                new PopulationDirective
                {
                    Name = nameof(FolderModel.Files)
                }
            });

            foreach (var file in folder.Files.Rows.ToList())
            {
                switch (EDiscoveryUtility.GetCurrentShareState(file))
                {
                case EDiscoveryShareState.NotShared:
                    // No Op here
                    break;

                case EDiscoveryShareState.Staged:
                    stats.FilesStaged++;
                    break;

                case EDiscoveryShareState.Published:
                    stats.FilesPublished++;
                    break;

                default:
                    break;
                }
            }

            stats.RecipientCount = folder.MetaEDiscoveryRecipientListRead().Count();

            stats.IsEDiscoveryActive = this.IsModuleActive(folder);

            return(stats);
        }
예제 #5
0
        public override void OverrideAllowedOperations(FileModel fileModel, List <AllowedOperation> allowed, PathIdentifier virtualPathIdentifier)
        {
            if (EDiscoveryUtility.IsEDiscoveryPath(virtualPathIdentifier))
            {
                allowed.Clear();
                allowed.Add(
                    AllowedOperation.GetAllowedOperationDownload(fileModel.Identifier, false)
                    );
                allowed.Add(
                    AllowedOperation.GetAllowedOperationDownloadZip(fileModel.Identifier)
                    );
            }

            // The allowed operations depend on what state the file is in.
            switch (EDiscoveryUtility.GetCurrentShareState(fileModel))
            {
            case EDiscoveryShareState.NotShared:
                // If the file hasn't been shared yet, we can "Share" it.
                allowed.Add(AllowedOperation.GetAllowedOperationShare(fileModel.Identifier, true));
                break;

            case EDiscoveryShareState.Staged:
                // If the file has only been staged, the we can "unshare" it.
                allowed.Add(AllowedOperation.GetAllowedOperationShare(fileModel.Identifier, false));
                break;

            case EDiscoveryShareState.Published:
                // If it's been published there isn't anything related to sharing that you can do on the file.
                // However if it's published we're not going to allow you to delete the file.
                allowed.RemoveAll(action => action.BatchOperation is DeleteRequest);
                allowed.RemoveAll(action => action.BatchOperation is RenameRequest);
                break;

            default:
                break;
            }
        }