Search in sources :

Example 6 with ProjectFileAccessProvider

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));
}
Also used : ProjectFileAccessProvider(org.finos.legend.sdlc.server.project.ProjectFileAccessProvider) LegendSDLCServerException(org.finos.legend.sdlc.server.error.LegendSDLCServerException) ProjectStructure(org.finos.legend.sdlc.server.project.ProjectStructure)

Aggregations

LegendSDLCServerException (org.finos.legend.sdlc.server.error.LegendSDLCServerException)6 ProjectFileAccessProvider (org.finos.legend.sdlc.server.project.ProjectFileAccessProvider)6 GitLabProjectId (org.finos.legend.sdlc.server.gitlab.GitLabProjectId)3 ProjectStructure (org.finos.legend.sdlc.server.project.ProjectStructure)3 MergeRequest (org.gitlab4j.api.models.MergeRequest)3 Revision (org.finos.legend.sdlc.domain.model.revision.Revision)2 DiffRef (org.gitlab4j.api.models.DiffRef)2 Project (org.finos.legend.sdlc.domain.model.project.Project)1 ProjectConfiguration (org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration)1 ProjectStructureVersion (org.finos.legend.sdlc.domain.model.project.configuration.ProjectStructureVersion)1 ProjectConfigurationUpdateBuilder (org.finos.legend.sdlc.server.project.ProjectConfigurationUpdateBuilder)1 GitLabApi (org.gitlab4j.api.GitLabApi)1 RepositoryApi (org.gitlab4j.api.RepositoryApi)1 Branch (org.gitlab4j.api.models.Branch)1