<PackageReference Include="Relativity.Server.Transfer.SDK" Version="7.7.0" />

FileShareService

using Relativity.Transfer.Dto; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; namespace Relativity.Transfer { internal class FileShareService : IFileShareService { private const string _END_POINT = "/Relativity.Rest/api/Relativity.StagingExplorer.Services.StagingManager.IStagingManagerModule/FileManagementService/"; private const string _COMMAND_QUERY = "QueryAsync"; private const string _COMMAND_QUERY_PROPERTIES = "QueryPropertiesAsync"; private const string _COMMAND_GET_ITEM = "GetItemAsync"; private const string _COMMAND_GET_ITEMS = "GetItemsAsync"; private const string _COMMAND_DELETE = "DeleteAsync"; private const string _COMMAND_ITEM_EXIST = "ItemExistsAsync"; private const string _COMMAND_ITEMS_EXIST = "ItemsExistAsync"; private readonly IFileShareRestClient _fileShareRestClient; private readonly int _fileShareId; private readonly bool _throwExceptions; internal FileShareService(RelativityConnectionInfo connectionInfo, ClientConfiguration configuration, int fileShareId, ITransferLog log, bool throwExceptions = true) { if (connectionInfo == null) throw new ArgumentNullException("connectionInfo"); if (log == null) throw new ArgumentNullException("log"); if (fileShareId <= 0) throw new ArgumentOutOfRangeException("fileShareId", fileShareId, "FileShare id should be greater than zero"); _fileShareRestClient = new FileShareRestClient(connectionInfo, configuration, log); _fileShareId = fileShareId; _throwExceptions = throwExceptions; } internal FileShareService(IFileShareRestClient restClient, int fileShareId, bool throwExceptions) { if (restClient == null) throw new ArgumentNullException("restClient"); if (fileShareId <= 0) throw new ArgumentOutOfRangeException("fileShareId", fileShareId, "FileShare id should be greater than zero"); _fileShareRestClient = restClient; _fileShareId = fileShareId; _throwExceptions = throwExceptions; } [AsyncStateMachine(typeof(<ItemExistsAsync>d__13))] public Task<bool> ItemExistsAsync(string path, CancellationToken token) { <ItemExistsAsync>d__13 stateMachine = default(<ItemExistsAsync>d__13); stateMachine.<>t__builder = AsyncTaskMethodBuilder<bool>.Create(); stateMachine.<>4__this = this; stateMachine.path = path; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<ItemsExistAsync>d__14))] public Task<bool> ItemsExistAsync(IEnumerable<string> paths, CancellationToken token) { <ItemsExistAsync>d__14 stateMachine = default(<ItemsExistAsync>d__14); stateMachine.<>t__builder = AsyncTaskMethodBuilder<bool>.Create(); stateMachine.<>4__this = this; stateMachine.paths = paths; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<DirectoryEmptyAsync>d__15))] public Task<bool> DirectoryEmptyAsync(string path, CancellationToken token) { <DirectoryEmptyAsync>d__15 stateMachine = default(<DirectoryEmptyAsync>d__15); stateMachine.<>t__builder = AsyncTaskMethodBuilder<bool>.Create(); stateMachine.<>4__this = this; stateMachine.path = path; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<GetFileShareItemAsync>d__16))] public Task<FileShareItem> GetFileShareItemAsync(string path, CancellationToken token) { <GetFileShareItemAsync>d__16 stateMachine = default(<GetFileShareItemAsync>d__16); stateMachine.<>t__builder = AsyncTaskMethodBuilder<FileShareItem>.Create(); stateMachine.<>4__this = this; stateMachine.path = path; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<GetFileShareItemsAsync>d__17))] public Task<IEnumerable<FileShareItem>> GetFileShareItemsAsync(IEnumerable<string> directories, IEnumerable<string> files, CancellationToken token) { <GetFileShareItemsAsync>d__17 stateMachine = default(<GetFileShareItemsAsync>d__17); stateMachine.<>t__builder = AsyncTaskMethodBuilder<IEnumerable<FileShareItem>>.Create(); stateMachine.<>4__this = this; stateMachine.directories = directories; stateMachine.files = files; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<BrowseDirectoryAsync>d__18))] public Task<BrowseDirectoryResponseDto> BrowseDirectoryAsync(string path, int page, int pageSize, int enumerateMax, CancellationToken token) { <BrowseDirectoryAsync>d__18 stateMachine = default(<BrowseDirectoryAsync>d__18); stateMachine.<>t__builder = AsyncTaskMethodBuilder<BrowseDirectoryResponseDto>.Create(); stateMachine.<>4__this = this; stateMachine.path = path; stateMachine.page = page; stateMachine.pageSize = pageSize; stateMachine.enumerateMax = enumerateMax; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<GetItemAttributesAsync>d__19))] public Task<QueryPropertiesResponseDto> GetItemAttributesAsync(string path, CancellationToken token) { <GetItemAttributesAsync>d__19 stateMachine = default(<GetItemAttributesAsync>d__19); stateMachine.<>t__builder = AsyncTaskMethodBuilder<QueryPropertiesResponseDto>.Create(); stateMachine.<>4__this = this; stateMachine.path = path; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<DeleteDirectoriesAsync>d__20))] public Task DeleteDirectoriesAsync(IEnumerable<string> paths, CancellationToken token) { <DeleteDirectoriesAsync>d__20 stateMachine = default(<DeleteDirectoriesAsync>d__20); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.paths = paths; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<DeleteFilesAsync>d__21))] public Task DeleteFilesAsync(IEnumerable<string> paths, CancellationToken token) { <DeleteFilesAsync>d__21 stateMachine = default(<DeleteFilesAsync>d__21); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.paths = paths; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<DeleteAsync>d__22))] private Task DeleteAsync(IEnumerable<string> paths, bool isFile, CancellationToken token) { <DeleteAsync>d__22 stateMachine = default(<DeleteAsync>d__22); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.paths = paths; stateMachine.isFile = isFile; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<SendFileShareMessage>d__23<, >))] internal Task<TResponse> SendFileShareMessage<TResponse, TRequest>(TRequest request, string command, CancellationToken token) where TResponse : FileShareResponseBaseDto, new { <SendFileShareMessage>d__23<TResponse, TRequest> stateMachine = default(<SendFileShareMessage>d__23<TResponse, TRequest>); stateMachine.<>t__builder = AsyncTaskMethodBuilder<TResponse>.Create(); stateMachine.<>4__this = this; stateMachine.request = request; stateMachine.command = command; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } internal bool IsValidResponse(FileShareOperationErrorCode responseError) { return responseError == FileShareOperationErrorCode.Unknown; } internal static string StandardizePathSeparator(string path) { return path.Replace('/', '\\'); } internal string RemoveLastSeparator(string path) { if (path.Length <= 1 || !path.EndsWith("\\")) return path; return path.Remove(path.Length - 1); } } }