Skip to content

Commit

Permalink
enable etag on latest version by resolving latest
Browse files Browse the repository at this point in the history
  • Loading branch information
YannanGao-gs committed Sep 23, 2024
1 parent 56e4ee5 commit 1a6ad30
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ default List<ProjectVersionEntities> getDependenciesEntitiesByClassifier(String
{
return getDependenciesEntitiesByClassifier(Arrays.asList(new ProjectVersion(groupId, artifactId, versionId)), classifier, transitive, includeOrigin);
}

String resolveVersionId(String groupId, String artifactId, String versionId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public EntitiesServiceImpl(Entities entities, ProjectsService projects)
@Override
public List<Entity> 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
Expand Down Expand Up @@ -146,6 +145,12 @@ public List<ProjectVersionEntities> getDependenciesEntitiesByClassifier(List<Pro
return getDependenciesEntities(projectDependencies, classifier, transitive, includeOrigin);
}

@Override
public String resolveVersionId(String groupId, String artifactId, String versionId)
{
return this.projects.resolveAliasesAndCheckVersionExists(groupId, artifactId, versionId);
}

private Object executeWithTrace(String label, Supplier<Object> functionToExecute)
{
return TracerFactory.get().executeWithTrace(label, () -> functionToExecute.get());
Expand Down

0 comments on commit 1a6ad30

Please sign in to comment.