public async Task <IList <BaseDocumentDto> > GetDocumentsAsync(string projectId, string branchName) { await _commonValidator.ProjectHaveToExists(projectId); await _commonValidator.BranchHaveToExists(projectId, branchName); var baseDocuments = new List <BaseDocumentDto>(); var files = await _fileSystemService.GetFilesAsync(projectId, branchName); foreach (var file in files) { var extension = Path.GetExtension(file); var mimeType = MimeTypeMap.GetMimeType(extension); var baseDocument = new BaseDocumentDto { Uri = file, Name = Path.GetFileName(file), ConentType = mimeType }; baseDocuments.Add(baseDocument); } return(baseDocuments); }
private bool IsIndexable(BaseDocumentDto document) { var fileExtension = Path.GetExtension(document.Uri); if (fileExtension == ".md") { return(true); } return(false); }
private DocumentIndexDto CreateDocumentIndex(string projectId, string branchName, ProjectDto project, BaseDocumentDto document, string documentContent) { string indexed = ClearContent(documentContent); string title = ClearTitle(document.Uri); var documentIndexDto = new DocumentIndexDto { Content = indexed, BranchName = branchName, ProjectName = project.Name, ProjectId = projectId, Title = title, Url = document.Uri, Id = ToAlphanumeric(document.Uri), Tags = project.Tags.ToArray() }; return(documentIndexDto); }
public async Task <string> GetDocumentContentAsync(string projectId, string branchName, BaseDocumentDto document) { var fileUri = document.Uri.Replace("/", ":"); var gatewayAddress = await _discoveryService.GetGatewayAddress(); var docuemntsAddress = $"{gatewayAddress}/projects/{projectId}/branches/{branchName}/documents/content/{fileUri}"; var client = GetClient(); var response = await client.GetAsync(docuemntsAddress); if (response.IsSuccessStatusCode) { var responseString = await response.Content.ReadAsStringAsync(); return(responseString); } var message = await response.Content.ReadAsStringAsync(); throw new DowonloadDocumentContentException($"Document wasn't successfully downloaded. Status code: {response.StatusCode}. Response message: '{message}'."); }
protected void SetDto(BaseDocumentDto dto) { SetDto((BaseDto)dto); Code = dto.Code; Name = dto.Name; }