use of org.finos.legend.sdlc.server.project.ProjectFileAccessProvider in project legend-sdlc by finos.
the class GitLabRevisionApi method getProjectEntityRevisionContext.
@Override
public RevisionAccessContext getProjectEntityRevisionContext(String projectId, String entityPath) {
LegendSDLCServerException.validateNonNull(projectId, "projectId may not be null");
LegendSDLCServerException.validateNonNull(entityPath, "entityPath may not be null");
if (!isValidEntityPath(entityPath)) {
throw new LegendSDLCServerException("Invalid entity path: " + entityPath, Status.BAD_REQUEST);
}
ProjectFileAccessProvider fileAccessProvider = getProjectFileAccessProvider();
ProjectFileAccessProvider.FileAccessContext fileAccessContext = fileAccessProvider.getFileAccessContext(projectId, null, null, null, null);
ProjectStructure projectStructure = ProjectStructure.getProjectStructure(fileAccessContext);
String filePath = projectStructure.findEntityFile(entityPath, fileAccessContext);
if (filePath == null) {
throw new LegendSDLCServerException("Cannot find entity \"" + entityPath + "\" in project " + projectId, Status.NOT_FOUND);
}
String canonicalizedFilePath = ProjectPaths.canonicalizeFile(filePath);
return new ProjectFileRevisionAccessContextWrapper(fileAccessProvider.getRevisionAccessContext(projectId, null, null, null, canonicalizedFilePath), new PackageablePathExceptionProcessor(entityPath, canonicalizedFilePath));
}
Aggregations