diff --git a/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-docs.adoc b/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-docs.adoc index 1ebfd54..e245421 100644 --- a/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-docs.adoc +++ b/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-docs.adoc @@ -18,7 +18,6 @@ quarkus.http.filter.images.header."Cache-Control"=max-age=432000 quarkus.http.filter.images.matches=/images/* %prod.quarkus.rest-client.onecx_product_store_internal.url=http://onecx-product-store-svc:8080 %prod.quarkus.rest-client.onecx_image_internal.url=http://onecx-product-store-svc:8080 -%prod.quarkus.rest-client.onecx_workspace_svc_external_v1.url=http://onecx-workspace-svc:8080 quarkus.openapi-generator.codegen.spec.onecx_product_store_internal_yaml.config-key=onecx_product_store_internal quarkus.openapi-generator.codegen.spec.onecx_product_store_internal_yaml.base-package=gen.org.tkit.onecx.product.store.client quarkus.openapi-generator.codegen.spec.onecx_product_store_internal_yaml.return-response=true @@ -32,16 +31,9 @@ quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.additional-api- quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.type-mappings.File=byte[] quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection; quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.enable-security-generation=false -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.config-key=onecx_workspace_svc_external_v1 -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.base-package=gen.org.tkit.onecx.workspace.client -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.return-response=true -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders; -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection; -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.enable-security-generation=false quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi %prod.quarkus.rest-client.onecx_product_store_internal.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter %prod.quarkus.rest-client.onecx_image_internal.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter -%prod.quarkus.rest-client.onecx_workspace_svc_external_v1.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter %prod.quarkus.oidc-client.client-id=${quarkus.application.name} ---- ==== @@ -101,3 +93,26 @@ app: defaultClientScopes: [ ocx-ps:all, ocx-ws:read, ocx-pm:read ] ---- +uct: + read: permission on all GET requests and POST search + write: permission on PUT, POST, PATCH requests, where objects are saved or updated + delete: permission on all DELETE requests + microservice: + read: permission on all GET requests and POST search + write: permission on PUT, POST, PATCH requests, where objects are saved or updated + delete: permission on all DELETE requests + slot: + read: permission on all GET requests and POST search + write: permission on PUT, POST, PATCH requests, where objects are saved or updated + delete: permission on all DELETE requests + image: + read: permission on all GET requests and POST search + write: permission on PUT, POST, PATCH requests, where objects are saved or updated + keycloak: + client: + enabled: true + spec: + kcConfig: + defaultClientScopes: [ ocx-ps:all, ocx-ws:read, ocx-pm:read ] +---- + diff --git a/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-extensions.adoc b/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-extensions.adoc index 4a10b82..fcc82bb 100644 --- a/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-extensions.adoc +++ b/docs/modules/onecx-product-store-bff/pages/onecx-product-store-bff-extensions.adoc @@ -59,38 +59,38 @@ h| Version | tkit-quarkus-log-cdi | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] -| 2.33.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] +| 2.36.0 | tkit-quarkus-log-rs | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] -| 2.33.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] +| 2.36.0 | tkit-quarkus-log-json | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] -| 2.33.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] +| 2.36.0 | tkit-quarkus-rest | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link] -| 2.33.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link] +| 2.36.0 | tkit-quarkus-rest-context | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest-context.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link] -| 2.33.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link] +| 2.36.0 | tkit-quarkus-jpa | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-jpa.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link] -| 2.33.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link] +| 2.36.0 | quarkus-hibernate-validator @@ -101,8 +101,8 @@ h| Version | onecx-permissions | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-permissions.html[Link] -| https://github.com/onecx/onecx-quarkus/blob/0.31.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link] -| 0.31.0 +| https://github.com/onecx/onecx-quarkus/blob/0.34.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link] +| 0.34.0 | quarkus-oidc @@ -113,14 +113,14 @@ h| Version | tkit-quarkus-security | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-security.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] -| 2.33.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.36.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] +| 2.36.0 | onecx-core | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link] | -| 0.31.0 +| 0.34.0 | quarkus-arc diff --git a/pom.xml b/pom.xml index dc8c86f..a8a0389 100644 --- a/pom.xml +++ b/pom.xml @@ -191,21 +191,6 @@ true - - workspace-svc-v1 - generate-resources - - wget - - - - https://raw.githubusercontent.com/onecx/onecx-workspace-svc/main/src/main/openapi/onecx-workspace-v1-openapi.yaml - - target/tmp/openapi - onecx-workspace-svc-external-v1.yaml - true - - onecx-image-internal generate-resources diff --git a/src/main/java/org/tkit/onecx/product/store/bff/rs/controllers/ProductsRestController.java b/src/main/java/org/tkit/onecx/product/store/bff/rs/controllers/ProductsRestController.java index 13c6bce..bf33a15 100644 --- a/src/main/java/org/tkit/onecx/product/store/bff/rs/controllers/ProductsRestController.java +++ b/src/main/java/org/tkit/onecx/product/store/bff/rs/controllers/ProductsRestController.java @@ -1,7 +1,5 @@ package org.tkit.onecx.product.store.bff.rs.controllers; -import java.util.Set; - import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.transaction.Transactional; @@ -23,9 +21,6 @@ import gen.org.tkit.onecx.product.store.client.api.ProductsInternalApi; import gen.org.tkit.onecx.product.store.client.api.SlotsInternalApi; import gen.org.tkit.onecx.product.store.client.model.*; -import gen.org.tkit.onecx.workspace.client.api.WorkspaceExternalApi; -import gen.org.tkit.onecx.workspace.client.model.WorkspacePageResult; -import gen.org.tkit.onecx.workspace.client.model.WorkspaceSearchCriteria; @LogService @ApplicationScoped @@ -36,10 +31,6 @@ public class ProductsRestController implements ProductsApiService { @Inject ProductsInternalApi client; - @RestClient - @Inject - WorkspaceExternalApi workspaceClient; - @RestClient @Inject MicroservicesInternalApi msClient; @@ -111,20 +102,9 @@ public Response getProduct(String id) { public Response getProductByName(String name) { try (Response response = client.getProductByName(name)) { Product resultProduct = response.readEntity(Product.class); - Set workspaceNames = null; - - try (Response workspaceResponse = workspaceClient - .searchWorkspaces(new WorkspaceSearchCriteria().productName(name))) { - var result = workspaceResponse.readEntity(WorkspacePageResult.class); - workspaceNames = mapper.workspaceNames(result); - } catch (WebApplicationException ex) { - // ignore exception - } - - ProductAndWorkspacesDTO resultProductDTO = mapper.mapProductWithWorkspaceNames(resultProduct, workspaceNames); + ProductDTO resultProductDTO = mapper.mapProduct(resultProduct); return Response.status(response.getStatus()).entity(resultProductDTO).build(); } - } @Override diff --git a/src/main/java/org/tkit/onecx/product/store/bff/rs/mappers/ProductsMapper.java b/src/main/java/org/tkit/onecx/product/store/bff/rs/mappers/ProductsMapper.java index 7c8188b..83eb3b9 100644 --- a/src/main/java/org/tkit/onecx/product/store/bff/rs/mappers/ProductsMapper.java +++ b/src/main/java/org/tkit/onecx/product/store/bff/rs/mappers/ProductsMapper.java @@ -9,19 +9,10 @@ import gen.org.tkit.onecx.product.store.bff.rs.internal.model.*; import gen.org.tkit.onecx.product.store.client.model.*; -import gen.org.tkit.onecx.workspace.client.model.WorkspaceAbstract; -import gen.org.tkit.onecx.workspace.client.model.WorkspacePageResult; @Mapper(uses = { OffsetDateTimeMapper.class }) public interface ProductsMapper { - default Set workspaceNames(WorkspacePageResult result) { - if (result == null || result.getStream() == null) { - return Set.of(); - } - return result.getStream().stream().map(WorkspaceAbstract::getDisplayName).collect(Collectors.toSet()); - } - CreateProductRequest mapCreateProduct(CreateProductRequestDTO createProduct); UpdateProductRequest mapUpdateProduct(UpdateProductRequestDTO updateProduct); @@ -52,11 +43,6 @@ default String map(Set classifications) { return ""; } - @Mapping(target = "removeClassificationsItem", ignore = true) - @Mapping(target = "removeWorkspacesItem", ignore = true) - @Mapping(target = "workspaces", source = "workspaceNames") - ProductAndWorkspacesDTO mapProductWithWorkspaceNames(Product resultProduct, Set workspaceNames); - @Mapping(target = "productName", source = "name") @Mapping(target = "appName", ignore = true) @Mapping(target = "appId", ignore = true) diff --git a/src/main/openapi/openapi-bff.yaml b/src/main/openapi/openapi-bff.yaml index 62828bd..c5dd115 100644 --- a/src/main/openapi/openapi-bff.yaml +++ b/src/main/openapi/openapi-bff.yaml @@ -340,7 +340,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ProductAndWorkspaces' + $ref: '#/components/schemas/Product' "400": description: Bad Request content: @@ -967,15 +967,6 @@ components: type: boolean provider: type: string - ProductAndWorkspaces: - type: object - allOf: - - $ref: '#/components/schemas/Product' - properties: - workspaces: - type: array - items: - type: string ProductAbstract: type: object required: diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2195efc..3123569 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,7 +16,6 @@ quarkus.http.filter.images.matches=/images/* # PROD %prod.quarkus.rest-client.onecx_product_store_internal.url=http://onecx-product-store-svc:8080 %prod.quarkus.rest-client.onecx_image_internal.url=http://onecx-product-store-svc:8080 -%prod.quarkus.rest-client.onecx_workspace_svc_external_v1.url=http://onecx-workspace-svc:8080 # BUILD # product-store client @@ -35,26 +34,15 @@ quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.additional-api- quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.type-mappings.File=byte[] quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection; quarkus.openapi-generator.codegen.spec.onecx_image_internal_yaml.enable-security-generation=false - -# workspace external client -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.config-key=onecx_workspace_svc_external_v1 -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.base-package=gen.org.tkit.onecx.workspace.client -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.return-response=true -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders; -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection; -quarkus.openapi-generator.codegen.spec.onecx_workspace_svc_external_v1_yaml.enable-security-generation=false - quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi # OIDC %prod.quarkus.rest-client.onecx_product_store_internal.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter %prod.quarkus.rest-client.onecx_image_internal.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter -%prod.quarkus.rest-client.onecx_workspace_svc_external_v1.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter %prod.quarkus.oidc-client.client-id=${quarkus.application.name} # DEV %dev.quarkus.rest-client.onecx_product_store_internal.url=http://onecx-product-store-svc -%dev.quarkus.rest-client.onecx_workspace_svc_external_v1.url=http://onecx-workspace-svc %dev.quarkus.oidc-client.auth-server-url=${quarkus.oidc.auth-server-url} %dev.quarkus.oidc-client.client-id=${quarkus.oidc.client-id} %dev.quarkus.oidc-client.credentials.secret=${quarkus.oidc.credentials.secret} @@ -76,7 +64,6 @@ quarkus.test.integration-test-profile=test %test.quarkus.mockserver.devservices.config-file=/mockserver.properties %test.quarkus.mockserver.devservices.config-dir=/mockserver %test.quarkus.rest-client.onecx_product_store_internal.url=${quarkus.mockserver.endpoint} -%test.quarkus.rest-client.onecx_workspace_svc_external_v1.url=${quarkus.mockserver.endpoint %test.quarkus.rest-client.onecx_image_internal.url=${quarkus.mockserver.endpoint} %test.tkit.rs.context.token.header-param=apm-principal-token diff --git a/src/test/java/org/tkit/onecx/product/store/bff/rs/ProductsRestControllerTest.java b/src/test/java/org/tkit/onecx/product/store/bff/rs/ProductsRestControllerTest.java index 4da37ff..56f167e 100644 --- a/src/test/java/org/tkit/onecx/product/store/bff/rs/ProductsRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/product/store/bff/rs/ProductsRestControllerTest.java @@ -14,7 +14,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockserver.client.MockServerClient; -import org.mockserver.matchers.Times; import org.mockserver.model.JsonBody; import org.mockserver.model.MediaType; import org.tkit.onecx.product.store.bff.rs.controllers.ProductsRestController; @@ -22,8 +21,6 @@ import gen.org.tkit.onecx.product.store.bff.rs.internal.model.*; import gen.org.tkit.onecx.product.store.client.model.*; -import gen.org.tkit.onecx.workspace.client.model.WorkspaceAbstract; -import gen.org.tkit.onecx.workspace.client.model.WorkspacePageResult; import io.quarkiverse.mockserver.test.InjectMockServerClient; import io.quarkus.test.common.http.TestHTTPEndpoint; import io.quarkus.test.junit.QuarkusTest; @@ -121,19 +118,6 @@ void getProductByName_test() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(data))); - var result = new WorkspacePageResult().stream( - List.of( - new WorkspaceAbstract().name("testWorkspace").displayName("testWorkspace") - .description("testWorkspace"))); - - // create mock rest endpoint - mockServerClient - .when(request().withPath("/v1/workspaces/search") - .withMethod(HttpMethod.POST), Times.exactly(1)) - .respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode()) - .withContentType(MediaType.APPLICATION_JSON) - .withBody(JsonBody.json(result))); - var response = given() .when() .auth().oauth2(keycloakClient.getAccessToken(ADMIN)) @@ -143,7 +127,7 @@ void getProductByName_test() { .then() .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) - .extract().as(ProductAndWorkspacesDTO.class); + .extract().as(ProductDTO.class); Assertions.assertNotNull(response); Assertions.assertEquals(data.getId(), response.getId()); @@ -161,7 +145,6 @@ void getProductByName_test() { Assertions.assertEquals(data.getIconName(), response.getIconName()); Assertions.assertEquals(Arrays.stream(data.getClassifications().split(",")).toArray().length, response.getClassifications().size()); - Assertions.assertEquals("testWorkspace", response.getWorkspaces().get(0)); // getByName for not existing name -> should return not found // create mock rest endpoint @@ -184,12 +167,6 @@ void getProductByName_test() { "https://prod.ucwe.capgemini.com/wp-content/uploads/2023/11/world-cloud-report-banner1_2023.jpg", "/app3", 0, "Product ABC", "Sun", "Themes, Menu"); - // create mock rest endpoint - mockServerClient - .when(request().withPath("/v1/workspaces/search") - .withMethod(HttpMethod.POST), Times.exactly(1)) - .respond(httpRequest -> response().withStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())); - // create mock rest endpoint mockServerClient .when(request().withPath(PRODUCT_STORE_SVC_INTERNAL_API_BASE_PATH + "/name/" + data2.getName()) @@ -198,7 +175,7 @@ void getProductByName_test() { .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(data2))); - var responseWithoutWorkspaces = given() + var response2 = given() .when() .auth().oauth2(keycloakClient.getAccessToken(ADMIN)) .header(APM_HEADER_PARAM, ADMIN) @@ -207,10 +184,9 @@ void getProductByName_test() { .then() .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) - .extract().as(ProductAndWorkspacesDTO.class); - Assertions.assertNotNull(responseWithoutWorkspaces); - Assertions.assertEquals(data2.getId(), responseWithoutWorkspaces.getId()); - Assertions.assertTrue(responseWithoutWorkspaces.getWorkspaces().isEmpty()); + .extract().as(ProductDTO.class); + Assertions.assertNotNull(response2); + Assertions.assertEquals(data2.getId(), response2.getId()); } /**