public List <RepositoryFile> GetFiles(string folderId, List <string> filePatternsToIgnore, out List <RepositoryFile> ignoredFiles) { Log.Information("Getting files for folder {folderId}", folderId); var retVal = new List <RepositoryFile>(); ignoredFiles = new List <RepositoryFile>(); var session = connectionFactory.ConnectToFirstRepository(); var folder = session.GetObject(folderId) as IFolder; if (folder != null) { var items = folder.GetChildren(); foreach (var item in items) { var document = item as IDocument; if (document?.IsLatestVersion != null && document.IsLatestVersion.Value) { var serializedProperties = JsonConvert.SerializeObject(document.Properties); Log.Verbose("Cmis Document {Id} contains the following properties {serializedProperties}", document.Id, serializedProperties); var extensions = document.GetExtensions(ExtensionLevel.Object); var repositoryFile = new RepositoryFile { Id = document.Id, LogicalName = document.Name, SizeInBytes = document.ContentStreamLength ?? 0, MimeType = document.ContentStreamMimeType, Hash = metadataAccess.GetExtendedPropertyValue(extensions, "Fixity Value"), HashAlgorithm = metadataAccess.GetExtendedPropertyValue(extensions, "Fixity Algorithm Ref"), SipOriginalName = metadataAccess.GetExtendedPropertyValue(extensions, "ARELDA:datei/datei/originalName"), SipId = metadataAccess.GetExtendedPropertyValue(extensions, "ARELDA:datei/datei@id") }; // Check if file should be ignored if (!filePatternsToIgnore.Any(fp => Regex.IsMatch(document.Name, fp, RegexOptions.IgnoreCase))) { retVal.Add(repositoryFile); } else { ignoredFiles.Add(repositoryFile); } } else if (document != null) { Log.Warning("Found an older version of a document (id: {Id}). Skipping document!", document.Id); } } } return(retVal); }
public async Task Consume(ConsumeContext <DirCheckRequest> context) { using (LogContext.PushProperty(nameof(context.ConversationId), context.ConversationId)) { Log.Information("Received {CommandName} command with conversationId {ConversationId} from the bus", nameof(DirCheckRequest), context.ConversationId); var response = new DirCheckResponse(); var session = connectionFactory.ConnectToFirstRepository(); response.Ok = session != null; if (session != null) { var repositoryInfo = session.RepositoryInfo; response.RepositoryName = repositoryInfo.Name; response.ProductVersion = repositoryInfo.ProductVersion; response.ProductName = repositoryInfo.ProductName; } await context.RespondAsync(response); } }