From 1a6ad309e1ba76c1a5669c088ebd6b2ed9987425 Mon Sep 17 00:00:00 2001 From: Yannan <73408381+YannanGao-gs@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:56:55 -0400 Subject: [PATCH] enable etag on latest version by resolving latest --- .../depot/services/api/entities/EntitiesService.java | 2 ++ .../server/resources/entities/EntitiesResource.java | 3 ++- .../depot/services/entities/EntitiesServiceImpl.java | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/legend-depot-entities-api/src/main/java/org/finos/legend/depot/services/api/entities/EntitiesService.java b/legend-depot-entities-api/src/main/java/org/finos/legend/depot/services/api/entities/EntitiesService.java index da306495d..6e2847e37 100644 --- a/legend-depot-entities-api/src/main/java/org/finos/legend/depot/services/api/entities/EntitiesService.java +++ b/legend-depot-entities-api/src/main/java/org/finos/legend/depot/services/api/entities/EntitiesService.java @@ -52,4 +52,6 @@ default List getDependenciesEntitiesByClassifier(String { return getDependenciesEntitiesByClassifier(Arrays.asList(new ProjectVersion(groupId, artifactId, versionId)), classifier, transitive, includeOrigin); } + + String resolveVersionId(String groupId, String artifactId, String versionId); } diff --git a/legend-depot-entities-services/src/main/java/org/finos/legend/depot/server/resources/entities/EntitiesResource.java b/legend-depot-entities-services/src/main/java/org/finos/legend/depot/server/resources/entities/EntitiesResource.java index c715c6e33..a9701fbab 100644 --- a/legend-depot-entities-services/src/main/java/org/finos/legend/depot/server/resources/entities/EntitiesResource.java +++ b/legend-depot-entities-services/src/main/java/org/finos/legend/depot/server/resources/entities/EntitiesResource.java @@ -61,7 +61,8 @@ public Response getEntities(@PathParam("groupId") String groupId, @PathParam("versionId") @ApiParam(value = VersionValidator.VALID_VERSION_ID_TXT) String versionId, @Context Request request) { - return handle(GET_VERSION_ENTITIES, () -> this.entitiesService.getEntities(groupId, artifactId, versionId), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, versionId).build()); + String resolvedVersionId = this.entitiesService.resolveVersionId(groupId, artifactId, versionId); + return handle(GET_VERSION_ENTITIES, () -> this.entitiesService.getEntities(groupId, artifactId, versionId), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, resolvedVersionId).build()); } @GET diff --git a/legend-depot-entities-services/src/main/java/org/finos/legend/depot/services/entities/EntitiesServiceImpl.java b/legend-depot-entities-services/src/main/java/org/finos/legend/depot/services/entities/EntitiesServiceImpl.java index ca8ad7760..b9609aeed 100644 --- a/legend-depot-entities-services/src/main/java/org/finos/legend/depot/services/entities/EntitiesServiceImpl.java +++ b/legend-depot-entities-services/src/main/java/org/finos/legend/depot/services/entities/EntitiesServiceImpl.java @@ -57,8 +57,7 @@ public EntitiesServiceImpl(Entities entities, ProjectsService projects) @Override public List getEntities(String groupId, String artifactId, String versionId) { - String version = this.projects.resolveAliasesAndCheckVersionExists(groupId, artifactId, versionId); - return entities.getAllEntities(groupId, artifactId, version); + return entities.getAllEntities(groupId, artifactId, resolveVersionId(groupId, artifactId, versionId)); } @Override @@ -146,6 +145,12 @@ public List getDependenciesEntitiesByClassifier(List functionToExecute) { return TracerFactory.get().executeWithTrace(label, () -> functionToExecute.get());