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 26, 2024
1 parent 56e4ee5 commit 5c64670
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.finos.legend.depot.services.api.entities.EntitiesService;
import org.finos.legend.depot.core.services.tracing.resources.TracingResource;
import org.finos.legend.depot.services.api.EtagBuilder;
import org.finos.legend.depot.services.api.projects.ProjectsService;

import javax.inject.Inject;
import javax.ws.rs.DefaultValue;
Expand All @@ -45,11 +46,13 @@
public class EntitiesResource extends TracingResource
{
private final EntitiesService entitiesService;
private final ProjectsService projectsService;

@Inject
public EntitiesResource(EntitiesService entitiesService)
public EntitiesResource(EntitiesService entitiesService, ProjectsService projectsService)
{
this.entitiesService = entitiesService;
this.projectsService = projectsService;
}

@GET
Expand All @@ -61,7 +64,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.projectsService.resolveAliasesAndCheckVersionExists(groupId, artifactId, versionId);
return handle(GET_VERSION_ENTITIES, () -> this.entitiesService.getEntities(groupId, artifactId, resolvedVersionId), 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,8 @@ 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);
String resolvedVersionId = this.projects.resolveAliasesAndCheckVersionExists(groupId, artifactId, versionId);
return entities.getAllEntities(groupId, artifactId, resolvedVersionId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.finos.legend.depot.domain.project.ProjectVersion;
import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService;
import org.finos.legend.depot.services.api.projects.ProjectsService;
import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry;
import org.finos.legend.depot.services.metrics.query.QueryMetricsServiceImpl;
import org.finos.legend.depot.store.model.projects.StoreProjectData;
Expand Down Expand Up @@ -60,8 +61,9 @@ public class TestEntitiesResource extends TestBaseServices
private final Queue queue = mock(Queue.class);
private UpdateEntities entitiesStore = new EntitiesMongo(mongoProvider);
private EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider);
private final EntitiesService entitiesService = new EntitiesServiceImpl(entitiesStore,new ProjectsServiceImpl(projectsVersions, projects, metricsRegistry, queue, new ProjectsConfiguration("master")));
private EntitiesResource entitiesResource = new EntitiesResource(entitiesService);
private ProjectsService projectsService = new ProjectsServiceImpl(projectsVersions, projects, metricsRegistry, queue, new ProjectsConfiguration("master"));
private final EntitiesService entitiesService = new EntitiesServiceImpl(entitiesStore,projectsService);
private EntitiesResource entitiesResource = new EntitiesResource(entitiesService, projectsService);
private QueryMetricsMongo metricsStore = new QueryMetricsMongo(mongoProvider);
private QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metricsStore);

Expand Down Expand Up @@ -135,7 +137,7 @@ public void canGetMetrics() throws InterruptedException
metricsHandler.persist(metricsRegistry);

Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime());
Assert.assertEquals(2, metricsStore.getAllStoredEntities().size());
Assert.assertEquals(3, metricsStore.getAllStoredEntities().size());
}

@Test
Expand Down

0 comments on commit 5c64670

Please sign in to comment.