diff --git a/README.md b/README.md index cb4544aec6..acecb6867f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![FINOS - Incubating](https://cdn.jsdelivr.net/gh/finos/contrib-toolbox@master/images/badge-incubating.svg)](https://finosfoundation.atlassian.net/wiki/display/FINOS/Incubating) -[![Maven Central](https://img.shields.io/maven-central/v/org.finos.legend.sdlc/legend-sdlc.svg?maxAge=2592000)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22legend-sdlc) +[![Maven Central](https://img.shields.io/maven-central/v/org.finos.legend.sdlc/legend-sdlc.svg)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22legend-sdlc) ![Build CI](https://github.com/finos/legend-sdlc/workflows/Build%20CI/badge.svg) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=legend-sdlc&metric=security_rating&token=69394360757d5e1356312ddfee658a6b205e2c97)](https://sonarcloud.io/dashboard?id=legend-sdlc) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=legend-sdlc&metric=bugs&token=69394360757d5e1356312ddfee658a6b205e2c97)](https://sonarcloud.io/dashboard?id=legend-sdlc) diff --git a/legend-sdlc-server/pom.xml b/legend-sdlc-server/pom.xml index 46326db562..747c01b0db 100644 --- a/legend-sdlc-server/pom.xml +++ b/legend-sdlc-server/pom.xml @@ -219,6 +219,10 @@ io.dropwizard dropwizard-lifecycle + + io.dropwizard + dropwizard-jersey + io.dropwizard.metrics metrics-healthchecks @@ -242,6 +246,41 @@ javax.ws.rs-api + + org.glassfish.jersey.core + jersey-client + + + + + org.glassfish.jersey.media + jersey-media-json-jackson + 2.35 + runtime + + + org.glassfish.hk2.external + * + + + com.fasterxml.jackson.module + * + + + jakarta.ws.rs + * + + + com.fasterxml.jackson.core + * + + + + org.apache.commons commons-compress diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/LegendSDLCServer.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/LegendSDLCServer.java index 9e3d712a0a..7525bc199d 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/LegendSDLCServer.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/LegendSDLCServer.java @@ -14,7 +14,10 @@ package org.finos.legend.sdlc.server; +import io.dropwizard.setup.Environment; +import org.eclipse.collections.api.factory.Maps; import org.finos.legend.sdlc.server.config.LegendSDLCServerConfiguration; +import org.glassfish.jersey.CommonProperties; public class LegendSDLCServer extends BaseLegendSDLCServer { @@ -23,6 +26,13 @@ public LegendSDLCServer(String mode) super(mode); } + @Override + public void run(LegendSDLCServerConfiguration configuration, Environment environment) + { + super.run(configuration, environment); + environment.jersey().getResourceConfig().setProperties(Maps.mutable.of(CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)); + } + @Override protected ServerPlatformInfo newServerPlatformInfo() { diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/GitLabProjectId.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/GitLabProjectId.java index bc5da411ea..d55c36394c 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/GitLabProjectId.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/GitLabProjectId.java @@ -23,15 +23,15 @@ public final class GitLabProjectId private static final char DELIMITER = '-'; private final String prefix; - private final int gitLabId; + private final long gitLabId; - private GitLabProjectId(String prefix, int gitLabId) + private GitLabProjectId(String prefix, long gitLabId) { this.prefix = prefix; this.gitLabId = gitLabId; } - public int getGitLabId() + public long getGitLabId() { return this.gitLabId; } @@ -54,7 +54,7 @@ public boolean equals(Object other) @Override public int hashCode() { - return Objects.hashCode(this.prefix) ^ this.gitLabId; + return Objects.hashCode(this.prefix) ^ Objects.hashCode(this.gitLabId); } @Override @@ -63,7 +63,7 @@ public String toString() return getProjectIdString(this.prefix, this.gitLabId); } - public static GitLabProjectId newProjectId(String prefix, int gitLabId) + public static GitLabProjectId newProjectId(String prefix, long gitLabId) { return new GitLabProjectId(prefix, gitLabId); } @@ -84,11 +84,11 @@ public static GitLabProjectId parseProjectId(String projectId) return newProjectId(separatorIndex == -1 ? null : projectId.substring(0, separatorIndex), parseGitLabId(projectId, separatorIndex)); } - private static int parseGitLabId(String projectId, int separatorIndex) + private static long parseGitLabId(String projectId, int separatorIndex) { try { - return Integer.parseInt(projectId.substring(separatorIndex + 1)); + return Long.parseLong(projectId.substring(separatorIndex + 1)); } catch (NumberFormatException e) { @@ -96,7 +96,7 @@ private static int parseGitLabId(String projectId, int separatorIndex) } } - private static String getProjectIdString(String prefix, int gitLabId) + private static String getProjectIdString(String prefix, long gitLabId) { return (prefix != null ? (prefix + DELIMITER) : "") + gitLabId; } diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/AbstractGitlabWorkflowApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/AbstractGitlabWorkflowApi.java index f1172f01b5..67051d521e 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/AbstractGitlabWorkflowApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/AbstractGitlabWorkflowApi.java @@ -14,9 +14,9 @@ package org.finos.legend.sdlc.server.gitlab.api; -import org.eclipse.collections.api.map.primitive.IntObjectMap; -import org.eclipse.collections.api.map.primitive.MutableIntObjectMap; -import org.eclipse.collections.impl.factory.primitive.IntObjectMaps; +import org.eclipse.collections.api.map.primitive.LongObjectMap; +import org.eclipse.collections.api.map.primitive.MutableLongObjectMap; +import org.eclipse.collections.impl.factory.primitive.LongObjectMaps; import org.finos.legend.sdlc.server.gitlab.GitLabConfiguration; import org.finos.legend.sdlc.server.gitlab.auth.GitLabUserContext; import org.finos.legend.sdlc.server.gitlab.tools.PagerTools; @@ -36,7 +36,7 @@ protected AbstractGitlabWorkflowApi(GitLabConfiguration gitLabConfiguration, Git super(gitLabConfiguration, userContext, backgroundTaskProcessor); } - protected Pipeline getMergeRequestPipeline(int gitLabProjectId, int mergeRequestId, int pipelineId) throws GitLabApiException + protected Pipeline getMergeRequestPipeline(long gitLabProjectId, long mergeRequestId, long pipelineId) throws GitLabApiException { return PagerTools.stream(getMergeRequestPipelines(gitLabProjectId, mergeRequestId)) .filter(p -> (p.getId() != null) && (p.getId() == pipelineId)) @@ -44,36 +44,36 @@ protected Pipeline getMergeRequestPipeline(int gitLabProjectId, int mergeRequest .orElse(null); } - protected Pager getMergeRequestPipelines(int gitLabProjectId, int mergeRequestId) throws GitLabApiException + protected Pager getMergeRequestPipelines(long gitLabProjectId, long mergeRequestId) throws GitLabApiException { MergeRequestApi mergeRequestApi = getGitLabApi().getMergeRequestApi(); return withRetries(() -> mergeRequestApi.getMergeRequestPipelines(gitLabProjectId, mergeRequestId, ITEMS_PER_PAGE)); } - protected Pipeline getRefPipeline(int gitLabProjectId, String ref, int pipelineId) throws GitLabApiException + protected Pipeline getRefPipeline(long gitLabProjectId, String ref, long pipelineId) throws GitLabApiException { PipelineApi pipelineApi = getGitLabApi().getPipelineApi(); Pipeline pipeline = withRetries(() -> pipelineApi.getPipeline(gitLabProjectId, pipelineId)); return ((pipeline != null) && ref.equals(pipeline.getRef())) ? pipeline : null; } - protected Pager getRefPipelines(int gitLabProjectId, String ref) throws GitLabApiException + protected Pager getRefPipelines(long gitLabProjectId, String ref) throws GitLabApiException { PipelineApi pipelineApi = getGitLabApi().getPipelineApi(); return withRetries(() -> pipelineApi.getPipelines(gitLabProjectId, null, null, ref, false, null, null, null, null, ITEMS_PER_PAGE)); } - protected IntObjectMap indexPipelinesById(Pager pager, boolean ignoreNullIds, boolean ignoreIdConflicts) + protected LongObjectMap indexPipelinesById(Pager pager, boolean ignoreNullIds, boolean ignoreIdConflicts) { return indexPipelinesById(PagerTools.stream(pager), ignoreNullIds, ignoreIdConflicts); } - protected IntObjectMap indexPipelinesById(Stream pipelines, boolean ignoreNullIds, boolean ignoreIdConflicts) + protected LongObjectMap indexPipelinesById(Stream pipelines, boolean ignoreNullIds, boolean ignoreIdConflicts) { - MutableIntObjectMap map = IntObjectMaps.mutable.empty(); + MutableLongObjectMap map = LongObjectMaps.mutable.empty(); pipelines.forEach(p -> { - Integer id = p.getId(); + Long id = p.getId(); if (id == null) { if (ignoreNullIds) diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/BaseGitLabApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/BaseGitLabApi.java index fc3d042cec..59d78dd116 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/BaseGitLabApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/BaseGitLabApi.java @@ -498,22 +498,22 @@ protected static Date toDateIfNotNull(Instant instant) return (instant == null) ? null : Date.from(instant); } - protected static Integer parseIntegerIdIfNotNull(String id) + protected static Long parseNumericIdIfNotNull(String id) { - return parseIntegerIdIfNotNull(id, null); + return parseNumericIdIfNotNull(id, null); } - protected static Integer parseIntegerIdIfNotNull(String id, Status errorStatus) + protected static Long parseNumericIdIfNotNull(String id, Status errorStatus) { - return (id == null) ? null : parseIntegerId(id, errorStatus); + return (id == null) ? null : parseNumericId(id, errorStatus); } - protected static int parseIntegerId(String id) + protected static long parseNumericId(String id) { - return parseIntegerId(id, null); + return parseNumericId(id, null); } - protected static int parseIntegerId(String id, Status errorStatus) + protected static long parseNumericId(String id, Status errorStatus) { try { @@ -770,7 +770,7 @@ protected MergeRequest getReviewMergeRequest(MergeRequestApi mergeRequestApi, Gi protected MergeRequest getReviewMergeRequest(MergeRequestApi mergeRequestApi, GitLabProjectId projectId, String reviewId, boolean includeRebaseInProgress) { - int mergeRequestId = parseIntegerId(reviewId); + long mergeRequestId = parseNumericId(reviewId); MergeRequest mergeRequest; try { diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabBuildApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabBuildApi.java index a81fb08f60..58edcda918 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabBuildApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabBuildApi.java @@ -150,7 +150,7 @@ private GitLabBuildAccessContext(String projectId) @Override public Build getBuild(String buildId) { - int pipelineId = parseIntegerIdIfNotNull(buildId); + long pipelineId = parseNumericIdIfNotNull(buildId); Pipeline pipeline; try { diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabIssueApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabIssueApi.java index 5b1cb97954..f3b04f17cc 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabIssueApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabIssueApi.java @@ -43,7 +43,7 @@ public Issue getIssue(String projectId, String issueId) try { GitLabProjectId gitLabProjectId = parseProjectId(projectId); - org.gitlab4j.api.models.Issue issue = withRetries(() -> getGitLabApi().getIssuesApi().getIssue(gitLabProjectId.getGitLabId(), parseIntegerIdIfNotNull(issueId))); + org.gitlab4j.api.models.Issue issue = withRetries(() -> getGitLabApi().getIssuesApi().getIssue(gitLabProjectId.getGitLabId(), parseNumericIdIfNotNull(issueId))); return fromGitLabIssue(issue); } catch (Exception e) @@ -62,7 +62,7 @@ public List getIssues(String projectId) try { GitLabProjectId gitLabProjectId = parseProjectId(projectId); - Pager pager = withRetries(() -> getGitLabApi().getIssuesApi().getIssues((Integer) gitLabProjectId.getGitLabId(), ITEMS_PER_PAGE)); + Pager pager = withRetries(() -> getGitLabApi().getIssuesApi().getIssues(gitLabProjectId.getGitLabId(), ITEMS_PER_PAGE)); return PagerTools.stream(pager).map(GitLabIssueApi::fromGitLabIssue).collect(PagerTools.listCollector(pager)); } catch (Exception e) @@ -103,7 +103,7 @@ public void deleteIssue(String projectId, String issueId) try { GitLabProjectId gitLabProjectId = parseProjectId(projectId); - withRetries(() -> getGitLabApi().getIssuesApi().deleteIssue(gitLabProjectId.getGitLabId(), parseIntegerIdIfNotNull(issueId))); + withRetries(() -> getGitLabApi().getIssuesApi().deleteIssue(gitLabProjectId.getGitLabId(), parseNumericIdIfNotNull(issueId))); } catch (LegendSDLCServerException e) { diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabProjectApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabProjectApi.java index 6d7d717294..e1893cb116 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabProjectApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabProjectApi.java @@ -242,7 +242,7 @@ public ImportReport importProject(String id, String groupId, String artifactId) GitLabProjectId projectId; if (id.chars().allMatch(Character::isDigit)) { - projectId = GitLabProjectId.newProjectId(this.getGitLabConfiguration().getProjectIdPrefix(), Integer.parseInt(id)); + projectId = GitLabProjectId.newProjectId(this.getGitLabConfiguration().getProjectIdPrefix(), Long.parseLong(id)); } else { diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabReviewApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabReviewApi.java index f06d20d104..76fd7e6dc0 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabReviewApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitLabReviewApi.java @@ -17,8 +17,8 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Sets; import org.eclipse.collections.api.list.MutableList; -import org.eclipse.collections.api.set.primitive.MutableIntSet; -import org.eclipse.collections.impl.factory.primitive.IntSets; +import org.eclipse.collections.api.set.primitive.MutableLongSet; +import org.eclipse.collections.impl.factory.primitive.LongSets; import org.eclipse.collections.impl.utility.Iterate; import org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration; import org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency; @@ -55,6 +55,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.inject.Inject; +import javax.ws.rs.core.Response.Status; import java.time.Instant; import java.util.Arrays; import java.util.Collections; @@ -65,8 +67,6 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.inject.Inject; -import javax.ws.rs.core.Response.Status; public class GitLabReviewApi extends GitLabApiWithFileAccess implements ReviewApi { @@ -104,7 +104,7 @@ else if (revisionIds instanceof Set) // TODO: we might want to do this differently since the number of revision IDs can be huge // we can have a threshold for which we change our strategy to to make a single call for // merge requests by the other criteria and then filter by revisionIds. - MutableIntSet mergeRequestIds = IntSets.mutable.empty(); + MutableLongSet mergeRequestIds = LongSets.mutable.empty(); CommitsApi commitsApi = getGitLabApi().getCommitsApi(); // Combine all MRs associated with each revision mergeRequestStream = revisionIdSet.stream().flatMap(revisionId -> @@ -896,12 +896,12 @@ private static Review fromGitLabMergeRequest(String projectId, MergeRequest merg return newReview(mergeRequest.getIid(), projectId, workspaceInfo, mergeRequest.getTitle(), mergeRequest.getDescription(), mergeRequest.getCreatedAt(), mergeRequest.getUpdatedAt(), mergeRequest.getClosedAt(), mergeRequest.getMergedAt(), mergeRequest.getState(), mergeRequest.getAuthor(), mergeRequest.getMergeCommitSha(), mergeRequest.getWebUrl(), mergeRequest.getLabels()); } - private static Review newReview(Integer reviewId, String projectId, WorkspaceInfo workspaceInfo, String title, String description, Date createdAt, Date lastUpdatedAt, Date closedAt, Date committedAt, String reviewState, AbstractUser author, String commitRevisionId, String webURL, List labels) + private static Review newReview(Long reviewId, String projectId, WorkspaceInfo workspaceInfo, String title, String description, Date createdAt, Date lastUpdatedAt, Date closedAt, Date committedAt, String reviewState, AbstractUser author, String commitRevisionId, String webURL, List labels) { return newReview(reviewId, projectId, workspaceInfo.getWorkspaceId(), workspaceInfo.getWorkspaceType(), title, description, createdAt, lastUpdatedAt, closedAt, committedAt, reviewState, author, commitRevisionId, webURL, labels); } - private static Review newReview(Integer reviewId, String projectId, String workspaceId, WorkspaceType workspaceType, String title, String description, Date createdAt, Date lastUpdatedAt, Date closedAt, Date committedAt, String reviewState, AbstractUser author, String commitRevisionId, String webURL, List labels) + private static Review newReview(Long reviewId, String projectId, String workspaceId, WorkspaceType workspaceType, String title, String description, Date createdAt, Date lastUpdatedAt, Date closedAt, Date committedAt, String reviewState, AbstractUser author, String commitRevisionId, String webURL, List labels) { return newReview(toStringIfNotNull(reviewId), projectId, workspaceId, workspaceType, title, description, toInstantIfNotNull(createdAt), toInstantIfNotNull(lastUpdatedAt), toInstantIfNotNull(closedAt), toInstantIfNotNull(committedAt), getReviewState(reviewState), fromGitLabAbstractUser(author), commitRevisionId, webURL, labels); } diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowApi.java index 956c8137d7..c89b747b7f 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowApi.java @@ -39,14 +39,14 @@ import org.gitlab4j.api.models.Pipeline; import org.gitlab4j.api.models.PipelineStatus; +import javax.inject.Inject; +import javax.ws.rs.core.Response; import java.time.Instant; import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Set; import java.util.stream.Stream; -import javax.inject.Inject; -import javax.ws.rs.core.Response; public class GitlabWorkflowApi extends AbstractGitlabWorkflowApi implements WorkflowApi { @@ -135,7 +135,7 @@ public WorkflowAccessContext getReviewWorkflowAccessContext(String projectId, St return new GitLabWorkflowAccessContext(gitLabProjectId) { @Override - protected Pipeline getPipeline(int pipelineId) throws GitLabApiException + protected Pipeline getPipeline(long pipelineId) throws GitLabApiException { return getMergeRequestPipeline(this.gitLabProjectId.getGitLabId(), mergeRequest.getIid(), pipelineId); } @@ -177,7 +177,7 @@ protected GitLabWorkflowAccessContext(String projectId) @Override public Workflow getWorkflow(String workflowId) { - int pipelineId = parseIntegerIdIfNotNull(workflowId); + long pipelineId = parseNumericIdIfNotNull(workflowId); Pipeline pipeline; try { @@ -274,7 +274,7 @@ public List getWorkflows(Iterable revisionIds, Iterable getPipelines() throws GitLabApiException; @@ -333,7 +333,7 @@ private RefWorkflowAccessContext(String projectId, String ref) } @Override - protected Pipeline getPipeline(int pipelineId) throws GitLabApiException + protected Pipeline getPipeline(long pipelineId) throws GitLabApiException { return getRefPipeline(this.gitLabProjectId.getGitLabId(), this.ref, pipelineId); } diff --git a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowJobApi.java b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowJobApi.java index b9e38003fc..b1dc7471f8 100644 --- a/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowJobApi.java +++ b/legend-sdlc-server/src/main/java/org/finos/legend/sdlc/server/gitlab/api/GitlabWorkflowJobApi.java @@ -15,7 +15,7 @@ package org.finos.legend.sdlc.server.gitlab.api; import org.eclipse.collections.api.list.MutableList; -import org.eclipse.collections.api.map.primitive.IntObjectMap; +import org.eclipse.collections.api.map.primitive.LongObjectMap; import org.eclipse.collections.impl.utility.Iterate; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.sdlc.domain.model.project.workspace.WorkspaceType; @@ -37,12 +37,12 @@ import org.gitlab4j.api.models.MergeRequest; import org.gitlab4j.api.models.Pipeline; +import javax.inject.Inject; +import javax.ws.rs.core.Response.Status; import java.time.Instant; import java.util.EnumSet; import java.util.List; import java.util.Set; -import javax.inject.Inject; -import javax.ws.rs.core.Response.Status; public class GitlabWorkflowJobApi extends AbstractGitlabWorkflowApi implements WorkflowJobApi { @@ -107,16 +107,16 @@ public WorkflowJobAccessContext getReviewWorkflowJobAccessContext(String project return new GitLabWorkflowJobAccessContext(projectId) { - private IntObjectMap pipelinesById; + private LongObjectMap pipelinesById; @Override - protected Pipeline getPipeline(int pipelineId) throws GitLabApiException + protected Pipeline getPipeline(long pipelineId) throws GitLabApiException { return getPipelinesById().get(pipelineId); } @Override - protected Job getJob(int pipelineId, int jobId) throws GitLabApiException + protected Job getJob(long pipelineId, long jobId) throws GitLabApiException { Job job = super.getJob(pipelineId, jobId); return ((job != null) && (getPipeline(pipelineId) != null)) ? job : null; @@ -128,7 +128,7 @@ protected String getInfoForException() return "review " + reviewId + " of project " + projectId; } - private IntObjectMap getPipelinesById() throws GitLabApiException + private LongObjectMap getPipelinesById() throws GitLabApiException { if (this.pipelinesById == null) { @@ -167,7 +167,7 @@ public List getWorkflowJobs(String workflowId, Iterable jobs; @@ -301,9 +301,9 @@ public WorkflowJob cancelWorkflowJob(String workflowId, String workflowJobId) return fromGitLabJob(result); } - protected int getWorkflowPipelineId(String workflowId) + protected long getWorkflowPipelineId(String workflowId) { - int pipelineId = parseIntegerId(workflowId); + long pipelineId = parseNumericId(workflowId); // Validate that the pipeline exists and is a workflow pipeline Pipeline pipeline; @@ -325,14 +325,14 @@ protected int getWorkflowPipelineId(String workflowId) return pipelineId; } - protected abstract Pipeline getPipeline(int pipelineId) throws GitLabApiException; + protected abstract Pipeline getPipeline(long pipelineId) throws GitLabApiException; protected Job getJob(String workflowId, String workflowJobId) { Job job; try { - job = getJob(parseIntegerId(workflowId), parseIntegerId(workflowJobId)); + job = getJob(parseNumericId(workflowId), parseNumericId(workflowJobId)); } catch (Exception e) { @@ -348,7 +348,7 @@ protected Job getJob(String workflowId, String workflowJobId) return job; } - protected Job getJob(int pipelineId, int jobId) throws GitLabApiException + protected Job getJob(long pipelineId, long jobId) throws GitLabApiException { JobApi jobApi = getGitLabApi().getJobApi(); Job job = withRetries(() -> jobApi.getJob(this.projectId.getGitLabId(), jobId)); @@ -374,13 +374,13 @@ private RefWorkflowJobAccessContext(String projectId, String ref) } @Override - protected Pipeline getPipeline(int pipelineId) throws GitLabApiException + protected Pipeline getPipeline(long pipelineId) throws GitLabApiException { return getRefPipeline(this.projectId.getGitLabId(), this.ref, pipelineId); } @Override - protected Job getJob(int pipelineId, int jobId) throws GitLabApiException + protected Job getJob(long pipelineId, long jobId) throws GitLabApiException { Job job = super.getJob(pipelineId, jobId); return ((job != null) && this.ref.equals(job.getRef())) ? job : null; diff --git a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTest.java b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTest.java index 3073be4ead..02988e92d6 100644 --- a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTest.java +++ b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTest.java @@ -16,6 +16,8 @@ import com.hubspot.dropwizard.guicier.GuiceBundle; import io.dropwizard.setup.Bootstrap; +import io.dropwizard.setup.Environment; +import org.eclipse.collections.api.factory.Maps; import org.finos.legend.sdlc.domain.model.entity.Entity; import org.finos.legend.sdlc.domain.model.project.Project; import org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency; @@ -28,6 +30,7 @@ import org.finos.legend.sdlc.server.inmemory.backend.InMemoryMixins; import org.finos.legend.sdlc.server.jackson.ProjectDependencyMixin; import org.finos.legend.sdlc.server.jackson.VersionIdMixin; +import org.glassfish.jersey.CommonProperties; public class LegendSDLCServerForTest extends BaseLegendSDLCServer { @@ -58,6 +61,13 @@ protected GuiceBundle buildGuiceBundle() return this.guiceBundle; } + @Override + public void run(LegendSDLCServerConfiguration configuration, Environment environment) + { + super.run(configuration, environment); + environment.jersey().getResourceConfig().setProperties(Maps.mutable.of(CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)); + } + @Override protected AbstractBaseModule buildBaseModule() { diff --git a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/TestGitLabProjectId.java b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/TestGitLabProjectId.java index 96822b518d..2f51e593cb 100644 --- a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/TestGitLabProjectId.java +++ b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/TestGitLabProjectId.java @@ -56,7 +56,7 @@ public void testGetProjectIdString() String prefix = "SOMEPREFIX"; for (int i = 0; i < 1024; i++) { - Project project = new Project().withId(i); + Project project = new Project().withId((long) i); Assert.assertEquals(prefix + "-" + i, GitLabProjectId.getProjectIdString(prefix, project)); Assert.assertEquals("" + i, GitLabProjectId.getProjectIdString(null, project)); } diff --git a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabEntityApiTestResource.java b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabEntityApiTestResource.java index 1ee827b387..24ef8a137f 100644 --- a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabEntityApiTestResource.java +++ b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabEntityApiTestResource.java @@ -161,8 +161,8 @@ public void runEntitiesInNormalUserWorkspaceWorkflowTest() throws GitLabApiExcep GitLabProjectId sdlcGitLabProjectId = GitLabProjectId.parseProjectId(projectId); MergeRequestApi mergeRequestApi = gitLabMemberUserContext.getGitLabAPI().getMergeRequestApi(); - int parsedMergeRequestId = Integer.parseInt(reviewId); - int gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); + long parsedMergeRequestId = Long.parseLong(reviewId); + long gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); String requiredStatus = "can_be_merged"; CallUntil callUntil = CallUntil.callUntil( @@ -308,8 +308,8 @@ public void runEntitiesInNormalGroupWorkspaceWorkflowTest() throws GitLabApiExce GitLabProjectId sdlcGitLabProjectId = GitLabProjectId.parseProjectId(projectId); MergeRequestApi mergeRequestApi = gitLabMemberUserContext.getGitLabAPI().getMergeRequestApi(); - int parsedMergeRequestId = Integer.parseInt(reviewId); - int gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); + long parsedMergeRequestId = Long.parseLong(reviewId); + long gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); String requiredStatus = "can_be_merged"; CallUntil callUntil = CallUntil.callUntil( diff --git a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabWorkspaceApiTestResource.java b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabWorkspaceApiTestResource.java index 6325d76814..3f83089876 100644 --- a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabWorkspaceApiTestResource.java +++ b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/gitlab/api/GitLabWorkspaceApiTestResource.java @@ -202,8 +202,8 @@ public void runUpdateUserWorkspaceWithRebaseNoConflictTest() throws GitLabApiExc GitLabProjectId sdlcGitLabProjectId = GitLabProjectId.parseProjectId(projectId); MergeRequestApi mergeRequestApi = gitLabMemberUserContext.getGitLabAPI().getMergeRequestApi(); - Integer parsedMergeRequestId = Integer.parseInt(reviewId); - Integer gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); + long parsedMergeRequestId = Long.parseLong(reviewId); + long gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); String requiredStatus = "can_be_merged"; CallUntil callUntil = CallUntil.callUntil( @@ -339,8 +339,8 @@ public void runUpdateGroupWorkspaceWithRebaseNoConflictTest() throws GitLabApiEx GitLabProjectId sdlcGitLabProjectId = GitLabProjectId.parseProjectId(projectId); MergeRequestApi mergeRequestApi = gitLabMemberUserContext.getGitLabAPI().getMergeRequestApi(); - Integer parsedMergeRequestId = Integer.parseInt(reviewId); - Integer gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); + long parsedMergeRequestId = Long.parseLong(reviewId); + long gitlabProjectId = sdlcGitLabProjectId.getGitLabId(); String requiredStatus = "can_be_merged"; CallUntil callUntil = CallUntil.callUntil( diff --git a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/resources/SDLCServerClientRule.java b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/resources/SDLCServerClientRule.java index bdf2190459..59bc8587b9 100644 --- a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/resources/SDLCServerClientRule.java +++ b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/resources/SDLCServerClientRule.java @@ -29,6 +29,8 @@ import org.finos.legend.sdlc.server.jackson.ProjectDependencyMixin; import org.finos.legend.sdlc.server.jackson.ProjectRevisionMixin; import org.finos.legend.sdlc.server.jackson.VersionIdMixin; +import org.glassfish.jersey.CommonProperties; +import org.glassfish.jersey.client.ClientConfig; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -81,7 +83,7 @@ private Client createClient() { JacksonJsonProvider jacksonJsonProvider = new JacksonJsonProvider(); jacksonJsonProvider.setMapper(this.objectMapper); - return ClientBuilder.newClient().register(jacksonJsonProvider); + return ClientBuilder.newBuilder().withConfig(new ClientConfig().property(CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)).build().register(jacksonJsonProvider); } } diff --git a/legend-sdlc-test-reports/pom.xml b/legend-sdlc-test-reports/pom.xml index 6e00ab7de4..b3153e21bc 100644 --- a/legend-sdlc-test-reports/pom.xml +++ b/legend-sdlc-test-reports/pom.xml @@ -219,16 +219,6 @@ - - - - - - - - - - org.finos.legend.sdlc legend-sdlc-test-utils diff --git a/pom.xml b/pom.xml index 1bf3172597..92b67ae2e7 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 1.3.17-1 10.2.0 3.0.0 - 4.16.0 + 5.0.1 30.0-jre 4.2.1 1.4.200 @@ -1276,7 +1276,6 @@ jersey-container-servlet-core ${jersey.version} - org.glassfish.jersey.core jersey-client