use of de.catma.document.source.contenthandler.SourceContentHandler in project catma by forTEXT.
the class GitSourceDocumentHandler method open.
public SourceDocument open(@Nonnull String projectId, @Nonnull String sourceDocumentId) throws IOException {
try (ILocalGitRepositoryManager localGitRepoManager = this.localGitRepositoryManager) {
String projectRootRepositoryName = GitProjectManager.getProjectRootRepositoryName(projectId);
localGitRepoManager.open(projectId, projectRootRepositoryName);
String sourceDocumentSubmoduleName = String.format("%s/%s", GitProjectHandler.SOURCE_DOCUMENT_SUBMODULES_DIRECTORY_NAME, sourceDocumentId);
File sourceDocumentSubmodulePath = new File(localGitRepoManager.getRepositoryWorkTree().toString(), sourceDocumentSubmoduleName);
File headerFile = new File(sourceDocumentSubmodulePath, HEADER_FILE_NAME);
String serializedHeaderFile = FileUtils.readFileToString(headerFile, StandardCharsets.UTF_8);
SourceDocumentInfo sourceDocumentInfo = new SerializationHelper<SourceDocumentInfo>().deserialize(serializedHeaderFile, SourceDocumentInfo.class);
SourceDocumentHandler sourceDocumentHandler = new SourceDocumentHandler();
SourceContentHandler sourceContentHandler = new StandardContentHandler();
sourceContentHandler.setSourceDocumentInfo(sourceDocumentInfo);
SourceDocument sourceDocument = sourceDocumentHandler.loadSourceDocument(sourceDocumentId, sourceContentHandler);
String sourceDocumentRevisionHash = localGitRepoManager.getSubmoduleHeadRevisionHash(sourceDocumentSubmoduleName);
sourceDocument.setRevisionHash(sourceDocumentRevisionHash);
return sourceDocument;
}
}
Aggregations