diff --git a/legend-depot-artifacts-api/pom.xml b/legend-depot-artifacts-api/pom.xml
index a1de865c6..0e2c01ed9 100644
--- a/legend-depot-artifacts-api/pom.xml
+++ b/legend-depot-artifacts-api/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-artifacts-repository-api/pom.xml b/legend-depot-artifacts-repository-api/pom.xml
index 75b14dedf..0836eaac4 100644
--- a/legend-depot-artifacts-repository-api/pom.xml
+++ b/legend-depot-artifacts-repository-api/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-artifacts-repository-maven-impl/pom.xml b/legend-depot-artifacts-repository-maven-impl/pom.xml
index ca18f83df..e786b579e 100644
--- a/legend-depot-artifacts-repository-maven-impl/pom.xml
+++ b/legend-depot-artifacts-repository-maven-impl/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-artifacts-services/pom.xml b/legend-depot-artifacts-services/pom.xml
index 29d55d3d4..f6d5d4e80 100644
--- a/legend-depot-artifacts-services/pom.xml
+++ b/legend-depot-artifacts-services/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-artifacts-store-mongo/pom.xml b/legend-depot-artifacts-store-mongo/pom.xml
index 428f5d3a8..e52cfcac0 100644
--- a/legend-depot-artifacts-store-mongo/pom.xml
+++ b/legend-depot-artifacts-store-mongo/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-authorisation/pom.xml b/legend-depot-core-authorisation/pom.xml
index c740e34f0..e489642d5 100644
--- a/legend-depot-core-authorisation/pom.xml
+++ b/legend-depot-core-authorisation/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-data-api/pom.xml b/legend-depot-core-data-api/pom.xml
index 2d822c0f8..be144e869 100644
--- a/legend-depot-core-data-api/pom.xml
+++ b/legend-depot-core-data-api/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-data-services/pom.xml b/legend-depot-core-data-services/pom.xml
index 2c2f21546..b557a1373 100644
--- a/legend-depot-core-data-services/pom.xml
+++ b/legend-depot-core-data-services/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-data-store-mongo/pom.xml b/legend-depot-core-data-store-mongo/pom.xml
index 46f28c8e2..9675e2419 100644
--- a/legend-depot-core-data-store-mongo/pom.xml
+++ b/legend-depot-core-data-store-mongo/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-schedules-api/pom.xml b/legend-depot-core-schedules-api/pom.xml
index d223f9490..b07cd59ff 100644
--- a/legend-depot-core-schedules-api/pom.xml
+++ b/legend-depot-core-schedules-api/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-schedules-api/src/main/java/org/finos/legend/depot/store/api/admin/schedules/ScheduleInstancesStore.java b/legend-depot-core-schedules-api/src/main/java/org/finos/legend/depot/store/api/admin/schedules/ScheduleInstancesStore.java
index 7b6ca9fab..227276b36 100644
--- a/legend-depot-core-schedules-api/src/main/java/org/finos/legend/depot/store/api/admin/schedules/ScheduleInstancesStore.java
+++ b/legend-depot-core-schedules-api/src/main/java/org/finos/legend/depot/store/api/admin/schedules/ScheduleInstancesStore.java
@@ -28,6 +28,6 @@ public interface ScheduleInstancesStore
void insert(ScheduleInstance instance);
- void delete(String instanceId);
+ long delete(long l);
}
diff --git a/legend-depot-core-schedules-store-mongo/pom.xml b/legend-depot-core-schedules-store-mongo/pom.xml
index 263c400fc..fc7651398 100644
--- a/legend-depot-core-schedules-store-mongo/pom.xml
+++ b/legend-depot-core-schedules-store-mongo/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/ScheduleInstancesMongo.java b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/ScheduleInstancesMongo.java
index 75417284b..1a9af1546 100644
--- a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/ScheduleInstancesMongo.java
+++ b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/ScheduleInstancesMongo.java
@@ -21,7 +21,6 @@
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.IndexModel;
import org.bson.conversions.Bson;
-import org.bson.types.ObjectId;
import org.finos.legend.depot.store.api.admin.schedules.ScheduleInstancesStore;
import org.finos.legend.depot.store.model.admin.schedules.ScheduleInstance;
import org.finos.legend.depot.store.mongo.core.BaseMongo;
@@ -32,11 +31,13 @@
import java.util.List;
import static com.mongodb.client.model.Filters.eq;
+import static com.mongodb.client.model.Filters.lt;
public class ScheduleInstancesMongo extends BaseMongo implements ScheduleInstancesStore
{
public static final String COLLECTION = "schedule-instances";
public static final String SCHEDULE = "schedule";
+ private static final String EXPIRES = "expires";
@Inject
@@ -75,9 +76,9 @@ public List getAll()
}
@Override
- public void delete(String instanceId)
+ public long delete(long expiry)
{
- super.delete(eq(ID_FIELD, new ObjectId(instanceId)));
+ return super.delete(lt(EXPIRES, expiry));
}
@Override
diff --git a/legend-depot-core-schedules/pom.xml b/legend-depot-core-schedules/pom.xml
index dffe1bbac..684893cb6 100644
--- a/legend-depot-core-schedules/pom.xml
+++ b/legend-depot-core-schedules/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-schedules/src/main/java/org/finos/legend/depot/services/schedules/SchedulesFactoryImpl.java b/legend-depot-core-schedules/src/main/java/org/finos/legend/depot/services/schedules/SchedulesFactoryImpl.java
index 340ac8a99..a7e972b89 100644
--- a/legend-depot-core-schedules/src/main/java/org/finos/legend/depot/services/schedules/SchedulesFactoryImpl.java
+++ b/legend-depot-core-schedules/src/main/java/org/finos/legend/depot/services/schedules/SchedulesFactoryImpl.java
@@ -34,6 +34,7 @@
import java.util.stream.Collectors;
import static org.finos.legend.depot.domain.DatesHandler.toDate;
+import static org.finos.legend.depot.domain.DatesHandler.toTime;
@Singleton
@@ -144,10 +145,9 @@ boolean canExecute(String name)
long deleteExpired()
{
- List expired = instancesStore.getAll().stream().filter(instance -> instance.isExpired()).collect(Collectors.toList());
- expired.forEach(instance -> this.instancesStore.delete(instance.getId()));
- LOGGER.info("Deleted {} expired schedule runs", expired.size());
- return expired.size();
+ long deletedInstancesCount = this.instancesStore.delete(toTime(LocalDateTime.now()));
+ LOGGER.info("Deleted {} expired schedule runs", deletedInstancesCount);
+ return deletedInstancesCount;
}
public void deRegister(String name)
diff --git a/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/MockInstancesStore.java b/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/MockInstancesStore.java
index 3ad199435..bd1fbed0c 100644
--- a/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/MockInstancesStore.java
+++ b/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/MockInstancesStore.java
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
class MockInstancesStore implements ScheduleInstancesStore
{
@@ -36,9 +37,11 @@ public void insert(ScheduleInstance instance)
}
@Override
- public void delete(String instanceId)
+ public long delete(long l)
{
- instances.removeIf(i -> instanceId.equals(i.getId()));
+ List toDeletedInstances = instances.stream().filter(i -> i.isExpired()).collect(Collectors.toList());
+ instances.removeAll(toDeletedInstances);
+ return toDeletedInstances.size();
}
@Override
diff --git a/legend-depot-core-store-api/pom.xml b/legend-depot-core-store-api/pom.xml
index 3a91e4f6c..0a82f152f 100644
--- a/legend-depot-core-store-api/pom.xml
+++ b/legend-depot-core-store-api/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-core-tracing/pom.xml b/legend-depot-core-tracing/pom.xml
index 6ea5adfc5..0e0307eff 100644
--- a/legend-depot-core-tracing/pom.xml
+++ b/legend-depot-core-tracing/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-entities-api/pom.xml b/legend-depot-entities-api/pom.xml
index a0e885748..a1fe61603 100644
--- a/legend-depot-entities-api/pom.xml
+++ b/legend-depot-entities-api/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-entities-services/pom.xml b/legend-depot-entities-services/pom.xml
index 2b0c23b06..b0398e71d 100644
--- a/legend-depot-entities-services/pom.xml
+++ b/legend-depot-entities-services/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
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 f3f3121e8..a4d3a7833 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
@@ -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;
@@ -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
@@ -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
diff --git a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java
index 088ae6616..1fc5f7b22 100644
--- a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java
+++ b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java
@@ -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;
@@ -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);
@@ -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
diff --git a/legend-depot-entities-store-mongo/pom.xml b/legend-depot-entities-store-mongo/pom.xml
index 259034bde..fcf9e376e 100644
--- a/legend-depot-entities-store-mongo/pom.xml
+++ b/legend-depot-entities-store-mongo/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-generations-api/pom.xml b/legend-depot-generations-api/pom.xml
index 767aab5db..9242afc14 100644
--- a/legend-depot-generations-api/pom.xml
+++ b/legend-depot-generations-api/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-generations-services/pom.xml b/legend-depot-generations-services/pom.xml
index 0fe6b831f..988e21ef3 100644
--- a/legend-depot-generations-services/pom.xml
+++ b/legend-depot-generations-services/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-generations-store-mongo/pom.xml b/legend-depot-generations-store-mongo/pom.xml
index eccea7f3c..195ce8a26 100644
--- a/legend-depot-generations-store-mongo/pom.xml
+++ b/legend-depot-generations-store-mongo/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-metrics-query-api/pom.xml b/legend-depot-metrics-query-api/pom.xml
index c0e932e26..2e537ddd8 100644
--- a/legend-depot-metrics-query-api/pom.xml
+++ b/legend-depot-metrics-query-api/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-metrics-query-services/pom.xml b/legend-depot-metrics-query-services/pom.xml
index 0832282c1..1a5daf921 100644
--- a/legend-depot-metrics-query-services/pom.xml
+++ b/legend-depot-metrics-query-services/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-metrics-query-store-mongo/pom.xml b/legend-depot-metrics-query-store-mongo/pom.xml
index c42cfd940..47a4d6512 100644
--- a/legend-depot-metrics-query-store-mongo/pom.xml
+++ b/legend-depot-metrics-query-store-mongo/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-model/pom.xml b/legend-depot-model/pom.xml
index 46283b2c2..2ca02743a 100644
--- a/legend-depot-model/pom.xml
+++ b/legend-depot-model/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-notifications-api/pom.xml b/legend-depot-notifications-api/pom.xml
index 901a28e80..1c0636394 100644
--- a/legend-depot-notifications-api/pom.xml
+++ b/legend-depot-notifications-api/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-notifications-queue-mongo/pom.xml b/legend-depot-notifications-queue-mongo/pom.xml
index 47b5fdc53..f827acd88 100644
--- a/legend-depot-notifications-queue-mongo/pom.xml
+++ b/legend-depot-notifications-queue-mongo/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-notifications-services/pom.xml b/legend-depot-notifications-services/pom.xml
index d1537c531..16b744ccd 100644
--- a/legend-depot-notifications-services/pom.xml
+++ b/legend-depot-notifications-services/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-notifications-store-mongo/pom.xml b/legend-depot-notifications-store-mongo/pom.xml
index 81f17104e..f9ad8ca03 100644
--- a/legend-depot-notifications-store-mongo/pom.xml
+++ b/legend-depot-notifications-store-mongo/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-pure-model-context/pom.xml b/legend-depot-pure-model-context/pom.xml
index a4819bd90..910b1f0f3 100644
--- a/legend-depot-pure-model-context/pom.xml
+++ b/legend-depot-pure-model-context/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-server/pom.xml b/legend-depot-server/pom.xml
index cfca6f640..40cd43374 100644
--- a/legend-depot-server/pom.xml
+++ b/legend-depot-server/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java b/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java
index d84096632..57d5b649e 100644
--- a/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java
+++ b/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java
@@ -17,6 +17,8 @@
import com.google.inject.Module;
import io.dropwizard.jersey.setup.JerseyEnvironment;
+import io.dropwizard.setup.Environment;
+import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.finos.legend.depot.core.server.BaseServer;
import org.finos.legend.depot.core.server.guice.ServerInfoModule;
import org.finos.legend.depot.server.configuration.DepotServerConfiguration;
@@ -42,7 +44,10 @@
import org.finos.legend.depot.store.mongo.guice.GenerationsStoreMongoModule;
import org.finos.legend.depot.core.services.guice.MonitoringModule;
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterRegistration;
import java.util.Arrays;
+import java.util.EnumSet;
import java.util.List;
public class LegendDepotServer extends BaseServer
@@ -98,4 +103,16 @@ public void registerJacksonJsonProvider(JerseyEnvironment jerseyEnvironment)
{
jerseyEnvironment.register(new LegendDepotServerJacksonJsonProvider());
}
+
+ @Override
+ protected void initialiseCors(Environment environment)
+ {
+ FilterRegistration.Dynamic corsFilter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_TIMING_ORIGINS_PARAM, "*");
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin,Access-Control-Allow-Credentials,x-b3-parentspanid,x-b3-sampled,x-b3-spanid,x-b3-traceid");
+ corsFilter.setInitParameter(CrossOriginFilter.CHAIN_PREFLIGHT_PARAM, "false");
+ corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");
+ }
}
diff --git a/legend-depot-server/src/test/resources/sample-server-config.json b/legend-depot-server/src/test/resources/sample-server-config.json
index eed23678a..cc69af3b0 100644
--- a/legend-depot-server/src/test/resources/sample-server-config.json
+++ b/legend-depot-server/src/test/resources/sample-server-config.json
@@ -44,6 +44,9 @@
"serviceName": "legend-depot-server",
"enabled": false
},
+ "exceptionMapper": {
+ "includeStackTrace": true
+ }
"logging": {
"level": "INFO",
"loggers": {
@@ -91,4 +94,4 @@
"org.pac4j.j2e.filter.CallbackFilter": 4,
"CORS": 5
}
-}
\ No newline at end of file
+}
diff --git a/legend-depot-servers-common/pom.xml b/legend-depot-servers-common/pom.xml
index b3218f658..2700c3670 100644
--- a/legend-depot-servers-common/pom.xml
+++ b/legend-depot-servers-common/pom.xml
@@ -20,7 +20,7 @@
legend-depot
org.finos.legend.depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/BaseServer.java b/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/BaseServer.java
index 6ef8a60bd..ed54b49f6 100644
--- a/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/BaseServer.java
+++ b/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/BaseServer.java
@@ -56,7 +56,6 @@ public abstract class BaseServer extends Applicat
{
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(BaseServer.class);
public static final String SERVER_STARTED = "server started";
- public static final boolean INCLUDE_STACK_TRACE = true;
protected BaseServer()
{
@@ -119,9 +118,9 @@ public void run(T configuration, Environment environment)
environment.jersey().setUrlPattern(configuration.getUrlPattern());
}
environment.jersey().register(MultiPartFeature.class);
- environment.jersey().register(new DepotServerExceptionMapper(isExceptionsIncludeStackTrace()));
+ environment.jersey().register(new DepotServerExceptionMapper(configuration.getExceptionMapperConfiguration().includeStackTrace()));
environment.jersey().register(new JsonProcessingExceptionMapper(true));
- environment.jersey().register(new CatchAllExceptionMapper(isExceptionsIncludeStackTrace()));
+ environment.jersey().register(new CatchAllExceptionMapper(configuration.getExceptionMapperConfiguration().includeStackTrace()));
registerJacksonJsonProvider(environment.jersey());
environment.healthChecks().register("HealthCheck", new HealthCheck()
@@ -139,11 +138,6 @@ protected Result check()
initialiseOpenTracing(environment);
}
- protected boolean isExceptionsIncludeStackTrace()
- {
- return INCLUDE_STACK_TRACE;
- }
-
protected abstract void registerJacksonJsonProvider(JerseyEnvironment jerseyEnvironment);
private void registerLifeCycleListener(T configuration, Environment environment)
@@ -198,14 +192,5 @@ private void initialisePrometheusMetrics(Environment environment)
environment.admin().addServlet("prometheus", new MetricsServlet(collectorRegistry)).addMapping("/prometheus");
}
- private void initialiseCors(Environment environment)
- {
- FilterRegistration.Dynamic corsFilter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
- corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
- corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
- corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_TIMING_ORIGINS_PARAM, "*");
- corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin,Access-Control-Allow-Credentials,x-b3-parentspanid,x-b3-sampled,x-b3-spanid,x-b3-traceid");
- corsFilter.setInitParameter(CrossOriginFilter.CHAIN_PREFLIGHT_PARAM, "false");
- corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");
- }
+ protected abstract void initialiseCors(Environment environment);
}
diff --git a/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/ServerConfiguration.java b/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/ServerConfiguration.java
index 6981b617a..bda7c19b4 100644
--- a/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/ServerConfiguration.java
+++ b/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/ServerConfiguration.java
@@ -20,6 +20,7 @@
import io.dropwizard.Configuration;
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
+import org.finos.legend.depot.core.server.error.configuration.ExceptionMapperConfiguration;
import org.finos.legend.depot.services.api.projects.configuration.ProjectsConfiguration;
import org.finos.legend.depot.core.services.api.tracing.configuration.OpenTracingConfiguration;
import org.finos.legend.depot.core.services.api.metrics.configuration.PrometheusConfiguration;
@@ -73,6 +74,9 @@ public class ServerConfiguration extends Configuration
@JsonProperty("urlPattern")
private String urlPattern;
+ @JsonProperty("exceptionMapper")
+ private ExceptionMapperConfiguration exceptionMapperConfiguration;
+
public String getDeployment()
{
return deployment;
@@ -103,6 +107,16 @@ public void setOpenTracingConfiguration(OpenTracingConfiguration openTracingConf
this.openTracingConfiguration = openTracingConfiguration;
}
+ public ExceptionMapperConfiguration getExceptionMapperConfiguration()
+ {
+ return exceptionMapperConfiguration != null ? exceptionMapperConfiguration : new ExceptionMapperConfiguration();
+ }
+
+ public void setExceptionMapperConfiguration(ExceptionMapperConfiguration exceptionMapperConfiguration)
+ {
+ this.exceptionMapperConfiguration = exceptionMapperConfiguration;
+ }
+
public String getSessionCookie()
{
return sessionCookie;
diff --git a/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/error/configuration/ExceptionMapperConfiguration.java b/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/error/configuration/ExceptionMapperConfiguration.java
new file mode 100644
index 000000000..88f2e5c45
--- /dev/null
+++ b/legend-depot-servers-common/src/main/java/org/finos/legend/depot/core/server/error/configuration/ExceptionMapperConfiguration.java
@@ -0,0 +1,34 @@
+// Copyright 2024 Goldman Sachs
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.finos.legend.depot.core.server.error.configuration;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ExceptionMapperConfiguration
+{
+ @JsonProperty
+ private boolean includeStackTrace = false;
+
+ public boolean includeStackTrace()
+ {
+ return includeStackTrace;
+ }
+
+ public void setIncludeStackTrace(boolean includeStackTrace)
+ {
+ this.includeStackTrace = includeStackTrace;
+ }
+}
diff --git a/legend-depot-store-mongo/pom.xml b/legend-depot-store-mongo/pom.xml
index 581b810f8..5cae625dd 100644
--- a/legend-depot-store-mongo/pom.xml
+++ b/legend-depot-store-mongo/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-store-server/pom.xml b/legend-depot-store-server/pom.xml
index 3e23c6b6f..10796be65 100644
--- a/legend-depot-store-server/pom.xml
+++ b/legend-depot-store-server/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java b/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java
index 4c350630d..f51bb07e5 100644
--- a/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java
+++ b/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java
@@ -18,6 +18,8 @@
import com.google.inject.Module;
import io.dropwizard.jersey.setup.JerseyEnvironment;
import io.dropwizard.setup.Bootstrap;
+import io.dropwizard.setup.Environment;
+import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.finos.legend.depot.core.server.BaseServer;
import org.finos.legend.depot.core.server.guice.ServerInfoModule;
import org.finos.legend.depot.core.services.guice.AuthorisationModule;
@@ -58,7 +60,10 @@
import org.finos.legend.depot.store.server.configuration.DepotStoreServerConfiguration;
import org.finos.legend.depot.store.server.guice.DepotStoreServerModule;
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterRegistration;
import java.util.Arrays;
+import java.util.EnumSet;
import java.util.List;
public class LegendDepotStoreServer extends BaseServer
@@ -142,4 +147,15 @@ protected List getServerModules()
);
}
+ @Override
+ protected void initialiseCors(Environment environment)
+ {
+ FilterRegistration.Dynamic corsFilter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_TIMING_ORIGINS_PARAM, "*");
+ corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin,Access-Control-Allow-Credentials,x-b3-parentspanid,x-b3-sampled,x-b3-spanid,x-b3-traceid");
+ corsFilter.setInitParameter(CrossOriginFilter.CHAIN_PREFLIGHT_PARAM, "false");
+ corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");
+ }
}
diff --git a/legend-depot-test-reports/pom.xml b/legend-depot-test-reports/pom.xml
index e6b221559..e7e6b2f40 100644
--- a/legend-depot-test-reports/pom.xml
+++ b/legend-depot-test-reports/pom.xml
@@ -20,7 +20,7 @@
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
4.0.0
diff --git a/pom.xml b/pom.xml
index abd9d1110..676b2c359 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
Legend Depot
org.finos.legend.depot
legend-depot
- 2.42.1-SNAPSHOT
+ 2.43.1-SNAPSHOT
pom