use of org.gitlab4j.api.models.DiffRef in project legend-sdlc by finos.
the class GitLabProjectConfigurationApi method getReviewFromProjectConfiguration.
@Override
public ProjectConfiguration getReviewFromProjectConfiguration(String projectId, String reviewId) {
LegendSDLCServerException.validateNonNull(projectId, "projectId may not be null");
LegendSDLCServerException.validateNonNull(reviewId, "reviewId may not be null");
GitLabProjectId gitLabProjectId = parseProjectId(projectId);
MergeRequest mergeRequest = getReviewMergeRequest(getGitLabApi(gitLabProjectId.getGitLabMode()).getMergeRequestApi(), gitLabProjectId, reviewId);
validateMergeRequestForComparison(mergeRequest);
DiffRef diffRef = mergeRequest.getDiffRefs();
if (diffRef != null && diffRef.getStartSha() != null && diffRef.getHeadSha() != null) {
String revisionId = diffRef.getStartSha();
return getProjectRevisionProjectConfiguration(projectId, revisionId);
} else {
throw new LegendSDLCServerException("Unable to get [from] revision info in project " + projectId + " for review " + reviewId);
}
}
use of org.gitlab4j.api.models.DiffRef in project legend-sdlc by finos.
the class GitLabComparisonApi method getReviewWorkspaceCreationComparison.
@Override
public Comparison getReviewWorkspaceCreationComparison(String projectId, String reviewId) {
LegendSDLCServerException.validateNonNull(projectId, "projectId may not be null");
LegendSDLCServerException.validateNonNull(reviewId, "reviewId may not be null");
GitLabProjectId gitLabProjectId = parseProjectId(projectId);
RepositoryApi repositoryApi = getGitLabApi(gitLabProjectId.getGitLabMode()).getRepositoryApi();
MergeRequest mergeRequest = getReviewMergeRequest(getGitLabApi(gitLabProjectId.getGitLabMode()).getMergeRequestApi(), gitLabProjectId, reviewId);
WorkspaceInfo workspaceInfo = parseWorkspaceBranchName(mergeRequest.getSourceBranch());
if (workspaceInfo == null) {
throw new LegendSDLCServerException("Unknown review in project " + projectId + ": " + reviewId, Response.Status.NOT_FOUND);
}
DiffRef diffRef = mergeRequest.getDiffRefs();
if ((diffRef == null) || (diffRef.getStartSha() == null) || (diffRef.getHeadSha() == null)) {
throw new LegendSDLCServerException("Unable to get revision info for review " + reviewId + " in project " + projectId);
}
String fromRevisionId = diffRef.getBaseSha();
String toRevisionId = diffRef.getHeadSha();
ProjectStructure fromProjectStructure = getProjectStructure(projectId, workspaceInfo.getWorkspaceId(), fromRevisionId, workspaceInfo.getWorkspaceType(), workspaceInfo.getWorkspaceAccessType());
ProjectStructure toProjectStructure = getProjectStructure(projectId, workspaceInfo.getWorkspaceId(), toRevisionId, workspaceInfo.getWorkspaceType(), workspaceInfo.getWorkspaceAccessType());
return getComparisonResult(gitLabProjectId, repositoryApi, fromRevisionId, toRevisionId, fromProjectStructure, toProjectStructure);
}
use of org.gitlab4j.api.models.DiffRef in project legend-sdlc by finos.
the class GitLabEntityApi method getReviewFromEntityAccessContext.
public EntityAccessContext getReviewFromEntityAccessContext(String projectId, String reviewId) {
LegendSDLCServerException.validateNonNull(projectId, "projectId may not be null");
LegendSDLCServerException.validateNonNull(reviewId, "reviewId may not be null");
GitLabProjectId gitLabProjectId = parseProjectId(projectId);
MergeRequest mergeRequest = getReviewMergeRequest(getGitLabApi(gitLabProjectId.getGitLabMode()).getMergeRequestApi(), gitLabProjectId, reviewId);
validateMergeRequestForComparison(mergeRequest);
DiffRef diffRef = mergeRequest.getDiffRefs();
if (diffRef != null && diffRef.getStartSha() != null && diffRef.getHeadSha() != null) {
String revisionId = diffRef.getStartSha();
return new GitLabEntityAccessContext() {
@Override
protected ProjectFileAccessProvider.FileAccessContext getFileAccessContext(ProjectFileAccessProvider projectFileAccessProvider) {
return projectFileAccessProvider.getFileAccessContext(projectId, null, null, null, revisionId);
}
@Override
protected String getInfoForException() {
return "review " + reviewId + " of project " + projectId;
}
};
} else {
throw new LegendSDLCServerException("Unable to get [from] revision info in project " + projectId + " for review " + reviewId);
}
}
use of org.gitlab4j.api.models.DiffRef in project legend-sdlc by finos.
the class GitLabEntityApi method getReviewToEntityAccessContext.
public EntityAccessContext getReviewToEntityAccessContext(String projectId, String reviewId) {
LegendSDLCServerException.validateNonNull(projectId, "projectId may not be null");
LegendSDLCServerException.validateNonNull(reviewId, "reviewId may not be null");
GitLabProjectId gitLabProjectId = parseProjectId(projectId);
MergeRequest mergeRequest = getReviewMergeRequest(getGitLabApi(gitLabProjectId.getGitLabMode()).getMergeRequestApi(), gitLabProjectId, reviewId);
validateMergeRequestForComparison(mergeRequest);
DiffRef diffRef = mergeRequest.getDiffRefs();
if (diffRef != null && diffRef.getStartSha() != null && diffRef.getHeadSha() != null) {
String revisionId = diffRef.getHeadSha();
return new GitLabEntityAccessContext() {
@Override
protected ProjectFileAccessProvider.FileAccessContext getFileAccessContext(ProjectFileAccessProvider projectFileAccessProvider) {
return projectFileAccessProvider.getFileAccessContext(projectId, null, null, null, revisionId);
}
@Override
protected String getInfoForException() {
return "review " + reviewId + " of project " + projectId;
}
};
} else {
throw new LegendSDLCServerException("Unable to get [to] revision info in project " + projectId + " for review " + reviewId);
}
}
use of org.gitlab4j.api.models.DiffRef in project legend-sdlc by finos.
the class GitLabProjectConfigurationApi method getReviewToProjectConfiguration.
@Override
public ProjectConfiguration getReviewToProjectConfiguration(String projectId, String reviewId) {
LegendSDLCServerException.validateNonNull(projectId, "projectId may not be null");
LegendSDLCServerException.validateNonNull(reviewId, "reviewId may not be null");
GitLabProjectId gitLabProjectId = parseProjectId(projectId);
MergeRequest mergeRequest = getReviewMergeRequest(getGitLabApi(gitLabProjectId.getGitLabMode()).getMergeRequestApi(), gitLabProjectId, reviewId);
validateMergeRequestForComparison(mergeRequest);
DiffRef diffRef = mergeRequest.getDiffRefs();
if (diffRef != null && diffRef.getStartSha() != null && diffRef.getHeadSha() != null) {
String revisionId = diffRef.getHeadSha();
return getProjectRevisionProjectConfiguration(projectId, revisionId);
} else {
throw new LegendSDLCServerException("Unable to get [to] revision info in project " + projectId + " for review " + reviewId);
}
}
Aggregations