diff --git a/catalog/service/impl/build.gradle.kts b/catalog/service/impl/build.gradle.kts index d1fdf97735c..dddc8abf20b 100644 --- a/catalog/service/impl/build.gradle.kts +++ b/catalog/service/impl/build.gradle.kts @@ -26,6 +26,7 @@ dependencies { implementation(project(":nessie-versioned-storage-common")) implementation(project(":nessie-model")) implementation(project(":nessie-services")) + implementation(project(":nessie-services-config")) implementation(project(":nessie-versioned-spi")) implementation(project(":nessie-tasks-api")) implementation(project(":nessie-tasks-service-async")) diff --git a/catalog/service/impl/src/main/java/org/projectnessie/catalog/service/impl/CatalogServiceImpl.java b/catalog/service/impl/src/main/java/org/projectnessie/catalog/service/impl/CatalogServiceImpl.java index fb920dbac9a..d9d6e2d5890 100644 --- a/catalog/service/impl/src/main/java/org/projectnessie/catalog/service/impl/CatalogServiceImpl.java +++ b/catalog/service/impl/src/main/java/org/projectnessie/catalog/service/impl/CatalogServiceImpl.java @@ -102,9 +102,15 @@ import org.projectnessie.model.GetMultipleContentsResponse; import org.projectnessie.model.Reference; import org.projectnessie.nessie.tasks.api.TasksService; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.ContentApiImpl; +import org.projectnessie.services.impl.TreeApiImpl; import org.projectnessie.services.spi.ContentService; import org.projectnessie.services.spi.TreeService; import org.projectnessie.storage.uri.StorageUri; +import org.projectnessie.versioned.VersionStore; import org.projectnessie.versioned.storage.common.persist.ObjId; import org.projectnessie.versioned.storage.common.persist.Persist; import org.slf4j.Logger; @@ -116,18 +122,34 @@ public class CatalogServiceImpl implements CatalogService { private static final Logger LOGGER = LoggerFactory.getLogger(CatalogServiceImpl.class); @Inject ObjectIO objectIO; - @Inject TreeService treeService; - @Inject ContentService contentService; + TreeService treeService; + ContentService contentService; + CatalogConfig catalogConfig; @Inject Persist persist; @Inject TasksService tasksService; @Inject BackendExceptionMapper backendExceptionMapper; - @Inject CatalogConfig catalogConfig; @Inject ServiceConfig serviceConfig; @Inject @Named("import-jobs") Executor executor; + public CatalogServiceImpl() { + this(null, null, null, null, null); + } + + @Inject + public CatalogServiceImpl( + ServerConfig serverConfig, + CatalogConfig catalogConfig, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext) { + this.catalogConfig = catalogConfig; + this.treeService = new TreeApiImpl(serverConfig, store, authorizer, accessContext); + this.contentService = new ContentApiImpl(serverConfig, store, authorizer, accessContext); + } + private IcebergStuff icebergStuff() { return new IcebergStuff( objectIO, diff --git a/catalog/service/impl/src/test/java/org/projectnessie/catalog/service/impl/AbstractCatalogService.java b/catalog/service/impl/src/test/java/org/projectnessie/catalog/service/impl/AbstractCatalogService.java index 3965d1b8572..f72fe94000f 100644 --- a/catalog/service/impl/src/test/java/org/projectnessie/catalog/service/impl/AbstractCatalogService.java +++ b/catalog/service/impl/src/test/java/org/projectnessie/catalog/service/impl/AbstractCatalogService.java @@ -86,14 +86,10 @@ import org.projectnessie.services.authz.Authorizer; import org.projectnessie.services.authz.BatchAccessChecker; import org.projectnessie.services.config.ServerConfig; -import org.projectnessie.services.impl.ConfigApiImpl; import org.projectnessie.services.impl.ContentApiImpl; -import org.projectnessie.services.impl.DiffApiImpl; import org.projectnessie.services.impl.TreeApiImpl; import org.projectnessie.services.rest.RestV2ConfigResource; import org.projectnessie.services.rest.RestV2TreeResource; -import org.projectnessie.services.spi.ConfigService; -import org.projectnessie.services.spi.DiffService; import org.projectnessie.versioned.VersionStore; import org.projectnessie.versioned.storage.common.persist.Persist; import org.projectnessie.versioned.storage.testextension.NessiePersist; @@ -270,16 +266,12 @@ public boolean sendStacktraceToClient() { VersionStore versionStore = new VersionStoreImpl(persist); Authorizer authorizer = context -> batchAccessCheckerFactory.apply(context); AccessContext accessContext = () -> () -> null; - ConfigService configService = - new ConfigApiImpl(config, versionStore, authorizer, accessContext, 2); treeService = new TreeApiImpl(config, versionStore, authorizer, accessContext); contentService = new ContentApiImpl(config, versionStore, authorizer, accessContext); - DiffService diffService = new DiffApiImpl(config, versionStore, authorizer, accessContext); RestV2TreeResource treeResource = - new RestV2TreeResource( - configService, treeService, contentService, diffService, emptyHttpHeaders()); + new RestV2TreeResource(config, versionStore, authorizer, accessContext, emptyHttpHeaders()); RestV2ConfigResource configResource = new RestV2ConfigResource(config, versionStore, authorizer, accessContext); api = diff --git a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1GenericResource.java b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1GenericResource.java index 725ba28f94a..60a9c32785e 100644 --- a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1GenericResource.java +++ b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1GenericResource.java @@ -43,7 +43,12 @@ import org.projectnessie.catalog.formats.iceberg.rest.IcebergConfigResponse; import org.projectnessie.catalog.service.api.CatalogCommit; import org.projectnessie.catalog.service.api.SnapshotReqParams; +import org.projectnessie.catalog.service.config.CatalogConfig; import org.projectnessie.catalog.service.rest.IcebergErrorMapper.IcebergEntityKind; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.versioned.VersionStore; /** * Handles Iceberg REST API v1 endpoints that are not strongly associated with a particular entity @@ -58,6 +63,20 @@ public class IcebergApiV1GenericResource extends IcebergApiV1ResourceBase { @Inject IcebergConfigurer icebergConfigurer; @Inject IcebergErrorMapper errorMapper; + public IcebergApiV1GenericResource() { + this(null, null, null, null, null); + } + + @Inject + public IcebergApiV1GenericResource( + ServerConfig serverConfig, + CatalogConfig catalogConfig, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext) { + super(serverConfig, catalogConfig, store, authorizer, accessContext); + } + @ServerExceptionMapper public Response mapException(Exception ex) { return errorMapper.toResponse(ex, IcebergEntityKind.UNKNOWN); diff --git a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1NamespaceResource.java b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1NamespaceResource.java index d98fa8980c1..7d47314f126 100644 --- a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1NamespaceResource.java +++ b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1NamespaceResource.java @@ -52,6 +52,7 @@ import org.projectnessie.catalog.formats.iceberg.rest.IcebergListNamespacesResponse; import org.projectnessie.catalog.formats.iceberg.rest.IcebergUpdateNamespacePropertiesRequest; import org.projectnessie.catalog.formats.iceberg.rest.IcebergUpdateNamespacePropertiesResponse; +import org.projectnessie.catalog.service.config.CatalogConfig; import org.projectnessie.catalog.service.config.WarehouseConfig; import org.projectnessie.catalog.service.rest.IcebergErrorMapper.IcebergEntityKind; import org.projectnessie.error.NessieContentNotFoundException; @@ -70,8 +71,12 @@ import org.projectnessie.model.Namespace; import org.projectnessie.model.Operations; import org.projectnessie.model.Reference; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; import org.projectnessie.services.spi.PagedResponseHandler; import org.projectnessie.storage.uri.StorageUri; +import org.projectnessie.versioned.VersionStore; /** Handles Iceberg REST API v1 endpoints that are associated with namespaces. */ @RequestScoped @@ -82,6 +87,20 @@ public class IcebergApiV1NamespaceResource extends IcebergApiV1ResourceBase { @Inject IcebergErrorMapper errorMapper; + public IcebergApiV1NamespaceResource() { + this(null, null, null, null, null); + } + + @Inject + public IcebergApiV1NamespaceResource( + ServerConfig serverConfig, + CatalogConfig catalogConfig, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext) { + super(serverConfig, catalogConfig, store, authorizer, accessContext); + } + @ServerExceptionMapper public Response mapException(Exception ex) { return errorMapper.toResponse(ex, IcebergEntityKind.NAMESPACE); diff --git a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ResourceBase.java b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ResourceBase.java index be66306465b..ceb1297ec34 100644 --- a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ResourceBase.java +++ b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ResourceBase.java @@ -32,7 +32,6 @@ import com.google.common.base.Splitter; import io.smallrye.mutiny.Uni; -import jakarta.inject.Inject; import java.io.IOException; import java.net.URI; import java.time.OffsetDateTime; @@ -70,17 +69,34 @@ import org.projectnessie.model.Operations; import org.projectnessie.model.Reference; import org.projectnessie.model.TableReference; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.ContentApiImpl; +import org.projectnessie.services.impl.TreeApiImpl; import org.projectnessie.services.spi.ContentService; import org.projectnessie.services.spi.PagedCountingResponseHandler; import org.projectnessie.services.spi.TreeService; +import org.projectnessie.versioned.VersionStore; abstract class IcebergApiV1ResourceBase extends AbstractCatalogResource { - @Inject TreeService treeService; - @Inject ContentService contentService; - @Inject ServerConfig serverConfig; - @Inject CatalogConfig catalogConfig; + final TreeService treeService; + final ContentService contentService; + final ServerConfig serverConfig; + final CatalogConfig catalogConfig; + + protected IcebergApiV1ResourceBase( + ServerConfig serverConfig, + CatalogConfig catalogConfig, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext) { + this.serverConfig = serverConfig; + this.catalogConfig = catalogConfig; + this.treeService = new TreeApiImpl(serverConfig, store, authorizer, accessContext); + this.contentService = new ContentApiImpl(serverConfig, store, authorizer, accessContext); + } protected Stream listContent( NamespaceRef namespaceRef, diff --git a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1S3SignResource.java b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1S3SignResource.java index 54b2a18a9a0..2620e183117 100644 --- a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1S3SignResource.java +++ b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1S3SignResource.java @@ -38,9 +38,14 @@ import org.projectnessie.catalog.formats.iceberg.rest.IcebergS3SignRequest; import org.projectnessie.catalog.formats.iceberg.rest.IcebergS3SignResponse; import org.projectnessie.catalog.service.api.SignerKeysService; +import org.projectnessie.catalog.service.config.CatalogConfig; import org.projectnessie.catalog.service.objtypes.SignerKey; import org.projectnessie.catalog.service.rest.IcebergErrorMapper.IcebergEntityKind; import org.projectnessie.model.ContentKey; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.versioned.VersionStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,6 +68,20 @@ public class IcebergApiV1S3SignResource extends IcebergApiV1ResourceBase { Clock clock = Clock.systemUTC(); + public IcebergApiV1S3SignResource() { + this(null, null, null, null, null); + } + + @Inject + public IcebergApiV1S3SignResource( + ServerConfig serverConfig, + CatalogConfig catalogConfig, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext) { + super(serverConfig, catalogConfig, store, authorizer, accessContext); + } + @ServerExceptionMapper public Response mapException(Exception ex) { return errorMapper.toResponse(ex, IcebergEntityKind.UNKNOWN); diff --git a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1TableResource.java b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1TableResource.java index 68d5ed8bd9e..31e21519d36 100644 --- a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1TableResource.java +++ b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1TableResource.java @@ -91,6 +91,7 @@ import org.projectnessie.catalog.service.api.CatalogEntityAlreadyExistsException; import org.projectnessie.catalog.service.api.SnapshotReqParams; import org.projectnessie.catalog.service.api.SnapshotResponse; +import org.projectnessie.catalog.service.config.CatalogConfig; import org.projectnessie.catalog.service.config.WarehouseConfig; import org.projectnessie.catalog.service.rest.IcebergErrorMapper.IcebergEntityKind; import org.projectnessie.error.NessieContentNotFoundException; @@ -106,7 +107,11 @@ import org.projectnessie.model.Operation.Delete; import org.projectnessie.model.Operation.Put; import org.projectnessie.model.Operations; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; import org.projectnessie.storage.uri.StorageUri; +import org.projectnessie.versioned.VersionStore; /** Handles Iceberg REST API v1 endpoints that are associated with tables. */ @RequestScoped @@ -118,6 +123,20 @@ public class IcebergApiV1TableResource extends IcebergApiV1ResourceBase { @Inject IcebergConfigurer icebergConfigurer; @Inject IcebergErrorMapper errorMapper; + public IcebergApiV1TableResource() { + this(null, null, null, null, null); + } + + @Inject + public IcebergApiV1TableResource( + ServerConfig serverConfig, + CatalogConfig catalogConfig, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext) { + super(serverConfig, catalogConfig, store, authorizer, accessContext); + } + @ServerExceptionMapper public Response mapException(Exception ex) { return errorMapper.toResponse(ex, IcebergEntityKind.TABLE); diff --git a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ViewResource.java b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ViewResource.java index e5167e28c9c..0bcf4db65e9 100644 --- a/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ViewResource.java +++ b/catalog/service/rest/src/main/java/org/projectnessie/catalog/service/rest/IcebergApiV1ViewResource.java @@ -61,6 +61,7 @@ import org.projectnessie.catalog.formats.iceberg.rest.IcebergUpdateRequirement; import org.projectnessie.catalog.service.api.SnapshotReqParams; import org.projectnessie.catalog.service.api.SnapshotResponse; +import org.projectnessie.catalog.service.config.CatalogConfig; import org.projectnessie.catalog.service.rest.IcebergErrorMapper.IcebergEntityKind; import org.projectnessie.error.NessieNotFoundException; import org.projectnessie.model.Branch; @@ -70,6 +71,10 @@ import org.projectnessie.model.ImmutableOperations; import org.projectnessie.model.Operation.Delete; import org.projectnessie.model.Operations; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.versioned.VersionStore; /** Handles Iceberg REST API v1 endpoints that are associated with views. */ @RequestScoped @@ -80,6 +85,20 @@ public class IcebergApiV1ViewResource extends IcebergApiV1ResourceBase { @Inject IcebergErrorMapper errorMapper; + public IcebergApiV1ViewResource() { + this(null, null, null, null, null); + } + + @Inject + public IcebergApiV1ViewResource( + ServerConfig serverConfig, + CatalogConfig catalogConfig, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext) { + super(serverConfig, catalogConfig, store, authorizer, accessContext); + } + @ServerExceptionMapper public Response mapException(Exception ex) { return errorMapper.toResponse(ex, IcebergEntityKind.VIEW); diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestConfigResource.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestConfigResource.java index c20696a7ffe..e479d2a9620 100644 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestConfigResource.java +++ b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestConfigResource.java @@ -22,7 +22,12 @@ import org.projectnessie.api.v1.http.HttpConfigApi; import org.projectnessie.model.NessieConfiguration; import org.projectnessie.model.ser.Views; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.ConfigApiImpl; import org.projectnessie.services.spi.ConfigService; +import org.projectnessie.versioned.VersionStore; /** REST endpoint to retrieve server settings. */ @RequestScoped @@ -33,12 +38,13 @@ public class RestConfigResource implements HttpConfigApi { // Mandated by CDI 2.0 public RestConfigResource() { - this(null); + this(null, null, null, null); } @Inject - public RestConfigResource(ConfigService configService) { - this.configService = configService; + public RestConfigResource( + ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { + this.configService = new ConfigApiImpl(config, store, authorizer, accessContext, 1); } @Override diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestConfigService.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestConfigService.java deleted file mode 100644 index 68cac432b73..00000000000 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestConfigService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2023 Dremio - * - * 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.projectnessie.services.rest; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import org.projectnessie.services.authz.AccessContext; -import org.projectnessie.services.authz.Authorizer; -import org.projectnessie.services.config.ServerConfig; -import org.projectnessie.services.impl.ConfigApiImpl; -import org.projectnessie.versioned.VersionStore; - -@ApplicationScoped -public class RestConfigService extends ConfigApiImpl { - // Mandated by CDI 2.0 - public RestConfigService() { - this(null, null, null, null); - } - - @Inject - public RestConfigService( - ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { - super(config, store, authorizer, accessContext, 1); - } -} diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestContentResource.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestContentResource.java index d35d2e12942..e06ff2d2f45 100644 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestContentResource.java +++ b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestContentResource.java @@ -26,7 +26,12 @@ import org.projectnessie.model.GetMultipleContentsRequest; import org.projectnessie.model.GetMultipleContentsResponse; import org.projectnessie.model.ser.Views; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.ContentApiImpl; import org.projectnessie.services.spi.ContentService; +import org.projectnessie.versioned.VersionStore; /** REST endpoint for the content-API. */ @RequestScoped @@ -41,12 +46,13 @@ public class RestContentResource implements HttpContentApi { // Mandated by CDI 2.0 public RestContentResource() { - this(null); + this(null, null, null, null); } @Inject - public RestContentResource(ContentService contentService) { - this.contentService = contentService; + public RestContentResource( + ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { + this.contentService = new ContentApiImpl(config, store, authorizer, accessContext); } private ContentService resource() { diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestContentService.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestContentService.java deleted file mode 100644 index 120424590a9..00000000000 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestContentService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2023 Dremio - * - * 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.projectnessie.services.rest; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; -import jakarta.validation.executable.ExecutableType; -import jakarta.validation.executable.ValidateOnExecution; -import org.projectnessie.services.authz.AccessContext; -import org.projectnessie.services.authz.Authorizer; -import org.projectnessie.services.config.ServerConfig; -import org.projectnessie.services.impl.ContentApiImpl; -import org.projectnessie.versioned.VersionStore; - -@RequestScoped -@ValidateOnExecution(type = ExecutableType.ALL) -public class RestContentService extends ContentApiImpl { - // Mandated by CDI 2.0 - public RestContentService() { - this(null, null, null, null); - } - - @Inject - public RestContentService( - ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { - super(config, store, authorizer, accessContext); - } -} diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestDiffResource.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestDiffResource.java index 7fd9fab9d9b..9e5b1e0a223 100644 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestDiffResource.java +++ b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestDiffResource.java @@ -28,8 +28,13 @@ import org.projectnessie.model.DiffResponse.DiffEntry; import org.projectnessie.model.ImmutableDiffResponse; import org.projectnessie.model.ser.Views; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.DiffApiImpl; import org.projectnessie.services.spi.DiffService; import org.projectnessie.services.spi.PagedResponseHandler; +import org.projectnessie.versioned.VersionStore; /** REST endpoint for the diff-API. */ @RequestScoped @@ -44,12 +49,13 @@ public class RestDiffResource implements HttpDiffApi { // Mandated by CDI 2.0 public RestDiffResource() { - this(null); + this(null, null, null, null); } @Inject - public RestDiffResource(DiffService diffService) { - this.diffService = diffService; + public RestDiffResource( + ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { + this.diffService = new DiffApiImpl(config, store, authorizer, accessContext); } private DiffService resource() { diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestDiffService.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestDiffService.java deleted file mode 100644 index ed6bd00293c..00000000000 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestDiffService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2023 Dremio - * - * 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.projectnessie.services.rest; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; -import jakarta.validation.executable.ExecutableType; -import jakarta.validation.executable.ValidateOnExecution; -import org.projectnessie.services.authz.AccessContext; -import org.projectnessie.services.authz.Authorizer; -import org.projectnessie.services.config.ServerConfig; -import org.projectnessie.services.impl.DiffApiImpl; -import org.projectnessie.versioned.VersionStore; - -@RequestScoped -@ValidateOnExecution(type = ExecutableType.ALL) -public class RestDiffService extends DiffApiImpl { - // Mandated by CDI 2.0 - public RestDiffService() { - this(null, null, null, null); - } - - @Inject - public RestDiffService( - ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { - super(config, store, authorizer, accessContext); - } -} diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestNamespaceResource.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestNamespaceResource.java index d96e267b8e6..cdf32042caa 100644 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestNamespaceResource.java +++ b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestNamespaceResource.java @@ -31,7 +31,12 @@ import org.projectnessie.model.GetNamespacesResponse; import org.projectnessie.model.Namespace; import org.projectnessie.model.ser.Views; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.NamespaceApiImpl; import org.projectnessie.services.spi.NamespaceService; +import org.projectnessie.versioned.VersionStore; /** REST endpoint for the namespace-API. */ @RequestScoped @@ -46,12 +51,13 @@ public class RestNamespaceResource implements HttpNamespaceApi { // Mandated by CDI 2.0 public RestNamespaceResource() { - this(null); + this(null, null, null, null); } @Inject - public RestNamespaceResource(NamespaceService namespaceService) { - this.namespaceService = namespaceService; + public RestNamespaceResource( + ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { + this.namespaceService = new NamespaceApiImpl(config, store, authorizer, accessContext); } private NamespaceService resource() { diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestNamespaceService.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestNamespaceService.java deleted file mode 100644 index 2d1540885c7..00000000000 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestNamespaceService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2023 Dremio - * - * 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.projectnessie.services.rest; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; -import jakarta.validation.executable.ExecutableType; -import jakarta.validation.executable.ValidateOnExecution; -import org.projectnessie.services.authz.AccessContext; -import org.projectnessie.services.authz.Authorizer; -import org.projectnessie.services.config.ServerConfig; -import org.projectnessie.services.impl.NamespaceApiImpl; -import org.projectnessie.versioned.VersionStore; - -@RequestScoped -@ValidateOnExecution(type = ExecutableType.ALL) -public class RestNamespaceService extends NamespaceApiImpl { - // Mandated by CDI 2.0 - public RestNamespaceService() { - this(null, null, null, null); - } - - @Inject - public RestNamespaceService( - ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { - super(config, store, authorizer, accessContext); - } -} diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestTreeResource.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestTreeResource.java index dfb4a51618c..7c52ed84ed0 100644 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestTreeResource.java +++ b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestTreeResource.java @@ -46,8 +46,13 @@ import org.projectnessie.model.Reference; import org.projectnessie.model.ReferencesResponse; import org.projectnessie.model.ser.Views; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.TreeApiImpl; import org.projectnessie.services.spi.PagedCountingResponseHandler; import org.projectnessie.services.spi.TreeService; +import org.projectnessie.versioned.VersionStore; /** REST endpoint for the tree-API. */ @RequestScoped @@ -62,12 +67,13 @@ public class RestTreeResource implements HttpTreeApi { // Mandated by CDI 2.0 public RestTreeResource() { - this(null); + this(null, null, null, null); } @Inject - public RestTreeResource(TreeService treeService) { - this.treeService = treeService; + public RestTreeResource( + ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { + this.treeService = new TreeApiImpl(config, store, authorizer, accessContext); } private TreeService resource() { diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestTreeService.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestTreeService.java deleted file mode 100644 index 677d604ec90..00000000000 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestTreeService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2023 Dremio - * - * 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.projectnessie.services.rest; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; -import jakarta.validation.executable.ExecutableType; -import jakarta.validation.executable.ValidateOnExecution; -import org.projectnessie.services.authz.AccessContext; -import org.projectnessie.services.authz.Authorizer; -import org.projectnessie.services.config.ServerConfig; -import org.projectnessie.services.impl.TreeApiImpl; -import org.projectnessie.versioned.VersionStore; - -@RequestScoped -@ValidateOnExecution(type = ExecutableType.ALL) -public class RestTreeService extends TreeApiImpl { - // Mandated by CDI 2.0 - public RestTreeService() { - this(null, null, null, null); - } - - @Inject - public RestTreeService( - ServerConfig config, VersionStore store, Authorizer authorizer, AccessContext accessContext) { - super(config, store, authorizer, accessContext); - } -} diff --git a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestV2TreeResource.java b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestV2TreeResource.java index 1b3ed979072..a3ae5b03078 100644 --- a/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestV2TreeResource.java +++ b/servers/rest-services/src/main/java/org/projectnessie/services/rest/RestV2TreeResource.java @@ -65,11 +65,19 @@ import org.projectnessie.model.ReferencesResponse; import org.projectnessie.model.SingleReferenceResponse; import org.projectnessie.model.ser.Views; +import org.projectnessie.services.authz.AccessContext; +import org.projectnessie.services.authz.Authorizer; +import org.projectnessie.services.config.ServerConfig; +import org.projectnessie.services.impl.ConfigApiImpl; +import org.projectnessie.services.impl.ContentApiImpl; +import org.projectnessie.services.impl.DiffApiImpl; +import org.projectnessie.services.impl.TreeApiImpl; import org.projectnessie.services.spi.ConfigService; import org.projectnessie.services.spi.ContentService; import org.projectnessie.services.spi.DiffService; import org.projectnessie.services.spi.PagedCountingResponseHandler; import org.projectnessie.services.spi.TreeService; +import org.projectnessie.versioned.VersionStore; /** REST endpoint for the tree-API. */ @RequestScoped @@ -89,15 +97,15 @@ public RestV2TreeResource() { @Inject public RestV2TreeResource( - ConfigService configService, - TreeService treeService, - ContentService contentService, - DiffService diffService, + ServerConfig config, + VersionStore store, + Authorizer authorizer, + AccessContext accessContext, HttpHeaders httpHeaders) { - this.configService = configService; - this.treeService = treeService; - this.contentService = contentService; - this.diffService = diffService; + this.configService = new ConfigApiImpl(config, store, authorizer, accessContext, 2); + this.treeService = new TreeApiImpl(config, store, authorizer, accessContext); + this.contentService = new ContentApiImpl(config, store, authorizer, accessContext); + this.diffService = new DiffApiImpl(config, store, authorizer, accessContext); this.httpHeaders = httpHeaders; } diff --git a/versioned/combined-cs/src/main/java/org/projectnessie/nessie/combined/CombinedClientBuilder.java b/versioned/combined-cs/src/main/java/org/projectnessie/nessie/combined/CombinedClientBuilder.java index 50b54f9b7e8..53b31f56eb1 100644 --- a/versioned/combined-cs/src/main/java/org/projectnessie/nessie/combined/CombinedClientBuilder.java +++ b/versioned/combined-cs/src/main/java/org/projectnessie/nessie/combined/CombinedClientBuilder.java @@ -24,10 +24,6 @@ import org.projectnessie.services.authz.AccessContext; import org.projectnessie.services.authz.Authorizer; import org.projectnessie.services.config.ServerConfig; -import org.projectnessie.services.impl.ConfigApiImpl; -import org.projectnessie.services.impl.ContentApiImpl; -import org.projectnessie.services.impl.DiffApiImpl; -import org.projectnessie.services.impl.TreeApiImpl; import org.projectnessie.services.rest.RestV2ConfigResource; import org.projectnessie.services.rest.RestV2TreeResource; import org.projectnessie.versioned.VersionStore; @@ -105,20 +101,11 @@ public boolean sendStacktraceToClient() { AccessContext accessContext = () -> null; - ConfigApiImpl configService = - new ConfigApiImpl(serverConfig, versionStore, authorizer, accessContext, 2); - TreeApiImpl treeService = - new TreeApiImpl(serverConfig, versionStore, authorizer, accessContext); - ContentApiImpl contentService = - new ContentApiImpl(serverConfig, versionStore, authorizer, accessContext); - DiffApiImpl diffService = - new DiffApiImpl(serverConfig, versionStore, authorizer, accessContext); - configResource = new RestV2ConfigResource(serverConfig, versionStore, authorizer, accessContext); treeResource = new RestV2TreeResource( - configService, treeService, contentService, diffService, emptyHttpHeaders()); + serverConfig, versionStore, authorizer, accessContext, emptyHttpHeaders()); // Optimistic cast... @SuppressWarnings("unchecked")