diff --git a/.factorypath b/.factorypath index 64aa78395684cdf667988ff5f0a9d23a40f8ff19..d2a264809b58dcdc44078350cbb1f15fa76deac4 100644 --- a/.factorypath +++ b/.factorypath @@ -1,4 +1,4 @@ <factorypath> - <factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/> - <factorypathentry kind="EXTJAR" id="C:\Users\ctranoris\.m2\repository\org\mapstruct\mapstruct-processor\1.5.3.Final\mapstruct-processor-1.5.3.Final.jar" enabled="true" runInBatchMode="false"/> + <factorypathentry kind="VARJAR" id="M2_REPO/org/mapstruct/mapstruct-processor/1.5.3.Final/mapstruct-processor-1.5.3.Final.jar" enabled="true" runInBatchMode="false"/> + <factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.28/lombok-1.18.28.jar" enabled="true" runInBatchMode="false"/> </factorypath> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb7d754baa751630b25598e182a30f062e9b6ebd..40be386b981d8564ef04539edebb44dc6a389d39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ include: - ci-templates/default.yml - ci-templates/build.yml rules: - - if: '$CI_COMMIT_REF_PROTECTED && $CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop"' + - if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop"' - project: osl/code/org.etsi.osl.main ref: develop @@ -29,7 +29,7 @@ include: - ci-templates/default.yml - ci-templates/build_unprotected.yml rules: - - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && !$CI_COMMIT_REF_PROTECTED' + - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_PROTECTED == "false"' maven_build: extends: .maven_build diff --git a/Dockerfile b/Dockerfile index e7a7b05cf8fe304860bd076a7163a384075171d4..5d9a1d4f60cd7487c9de71a8f0057930e7637841 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ibm-semeru-runtimes:open-17.0.7_7-jdk # RUN mkdir /opt/shareclasses RUN mkdir -p /opt/openslice/lib/ -COPY target/org.etsi.osl.tmf.api-1.0.0-exec.jar /opt/openslice/lib/ -CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.tmf.api-1.0.0-exec.jar"] +COPY target/org.etsi.osl.tmf.api-1.1.0-exec.jar /opt/openslice/lib/ +CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.tmf.api-1.1.0-exec.jar"] EXPOSE 13082 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 885c3062d39c252078cdaf8636c69305ec312f2a..3184b3aa8216683e03259ec2967b84fd4309139e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,14 +5,21 @@ <parent> <groupId>org.etsi.osl</groupId> <artifactId>org.etsi.osl.main</artifactId> - <version>1.0.0</version> + <version>2024Q4</version> <relativePath>../org.etsi.osl.main</relativePath> </parent> + <version>${org.etsi.osl.tmf.api.version}</version> <artifactId>org.etsi.osl.tmf.api</artifactId> <name>org.etsi.osl.tmf.api</name> + <organization> + <name>OpenSlice by ETSI</name> + <url>https://osl.etsi.org</url> + </organization> + + <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -289,6 +296,12 @@ <artifactId>junit-platform-runner</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-inline</artifactId> + <version>4.0.0</version> + <scope>test</scope> + </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> @@ -431,6 +444,12 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.2.5</version> + <configuration> + <!-- Disable parallel execution --> + <parallel>none</parallel> + <runOrder>alphabetical</runOrder> + <forkCount>1</forkCount> + </configuration> </plugin> <plugin> <groupId>org.jacoco</groupId> @@ -452,11 +471,6 @@ </executions> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>3.2.5</version> - </plugin> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> diff --git a/src/main/java/org/etsi/osl/tmf/BootstrapResources.java b/src/main/java/org/etsi/osl/tmf/BootstrapResources.java index dacfb02b6c0f9c82d758949409ef662b163cadaf..9fdf7d78bef6387c0785fa72049565c20b547ef8 100644 --- a/src/main/java/org/etsi/osl/tmf/BootstrapResources.java +++ b/src/main/java/org/etsi/osl/tmf/BootstrapResources.java @@ -22,8 +22,10 @@ package org.etsi.osl.tmf; import com.fasterxml.jackson.databind.ObjectMapper; import org.etsi.osl.domain.model.kubernetes.KubernetesCRDV1; import org.etsi.osl.domain.model.kubernetes.KubernetesCRV1; +import org.etsi.osl.domain.model.kubernetes.KubernetesConfigMap; import org.etsi.osl.domain.model.kubernetes.KubernetesContextDefinition; import org.etsi.osl.domain.model.kubernetes.KubernetesSecret; +import org.etsi.osl.domain.model.kubernetes.KubernetesService; import org.etsi.osl.tmf.rcm634.model.ResourceCandidateUpdate; import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; import org.etsi.osl.tmf.rcm634.model.ResourceCatalogCreate; @@ -207,19 +209,42 @@ public class BootstrapResources { this.addToCategory( scategoryInfra, rspecKubCRV1 ); } - resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( - KubernetesSecret.OSL_KUBSECRET_RSPEC_NAME , - KubernetesSecret.OSL_KUBSECRET_RSPEC_VERSION); + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( + KubernetesSecret.OSL_KUBSECRET_RSPEC_NAME , + KubernetesSecret.OSL_KUBSECRET_RSPEC_VERSION); - if ( ( scategoryInfra != null ) && ( resourceSpecificationObj == null )) - { - ResourceSpecification rspecKubSecret = - this.resourceSpecRepoService.addResourceSpecification( KubernetesSecret.builder().build().toRSpecCreate_InitRepo() ); - KubernetesSecret.builder().build().fromRSpec(rspecKubSecret);//to update any details - this.addToCategory( scategoryInfra, rspecKubSecret ); - } + if ( ( scategoryInfra != null ) && ( resourceSpecificationObj == null )) + { + ResourceSpecification rspecKubSecret = + this.resourceSpecRepoService.addResourceSpecification( KubernetesSecret.builder().build().toRSpecCreate_InitRepo() ); + KubernetesSecret.builder().build().fromRSpec(rspecKubSecret);//to update any details + this.addToCategory( scategoryInfra, rspecKubSecret ); + } + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( + KubernetesService.OSL_KUBSERVICE_RSPEC_NAME , + KubernetesService.OSL_KUBSERVICE_RSPEC_VERSION); + + if ( ( scategoryInfra != null ) && ( resourceSpecificationObj == null )) + { + ResourceSpecification rspecKubServ = + this.resourceSpecRepoService.addResourceSpecification( KubernetesService.builder().build().toRSpecCreate_InitRepo() ); + KubernetesService.builder().build().fromRSpec(rspecKubServ);//to update any details + this.addToCategory( scategoryInfra, rspecKubServ ); + } + + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( + KubernetesConfigMap.OSL_KUBCMAP_RSPEC_NAME , + KubernetesConfigMap.OSL_KUBCMAP_RSPEC_VERSION); + + if ( ( scategoryInfra != null ) && ( resourceSpecificationObj == null )) + { + ResourceSpecification rspecKubCMap = + this.resourceSpecRepoService.addResourceSpecification( KubernetesConfigMap.builder().build().toRSpecCreate_InitRepo() ); + KubernetesConfigMap.builder().build().fromRSpec( rspecKubCMap );//to update any details + this.addToCategory( scategoryInfra, rspecKubCMap ); + } } diff --git a/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java b/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java index 239be290194fb3da0c4bd4c908d742c492c08ef9..b8e5b11ab5d362a73dc607ebe8a56453a7d04132 100644 --- a/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java +++ b/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java @@ -73,7 +73,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -109,7 +109,7 @@ public class SwaggerDocumentationConfig { .description("## TMF API Reference: TMF620 - Product Catalog Management ### Release : 19.0 - June 2019 Product Catalog API is one of Catalog Management API Family. Product Catalog API goal is to provide a catalog of products. ### Operations Product Catalog API performs the following operations on the resources : - Retrieve an entity or a collection of entities depending on filter criteria - Partial update of an entity (including updating rules) - Create an entity (including default values and creation rules) - Delete an entity - Manage notification of events") .version("4.0.0") - .license(new License().name("Apache 2.0").url("http://openslice.io"))) + .license(new License().name("Apache 2.0").url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -139,7 +139,7 @@ public class SwaggerDocumentationConfig { @Bean - public OpenApiCustomizer scm622OpenAPI() { + public OpenApiCustomizer po622OpenAPI() { return openApi -> openApi .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) .info(new Info().title("TMF 622 Product Ordering") @@ -148,7 +148,7 @@ public class SwaggerDocumentationConfig { .version("1.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -161,12 +161,48 @@ public class SwaggerDocumentationConfig { SpringDocUtils.getConfig().replaceWithClass(java.time.OffsetDateTime.class, java.util.Date.class); return GroupedOpenApi.builder() .group("tmf-api-622-ProductOrderingManagement-v4.0.0") - .addOpenApiCustomizer( this.scm622OpenAPI() ) + .addOpenApiCustomizer( this.po622OpenAPI() ) .packagesToScan("org.etsi.osl.tmf.po622.api") .build(); } + + /** + * TMF 637 Product Inventory Management + * @return + */ + @Bean + public OpenApiCustomizer pim637penAPI() { + + + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 637 Product Inventory Management") + .description("**TMF API Reference : TMF 637 - Product Inventory Management** Release : 19.0 - June 2019\n\nThe Product Inventory Management API provides standardized mechanism for product inventory management such as creation, update and retrieval of the representation of a product in the inventory. It also allows the notification of events related to product lifecycle **Product resource** A product offering procured by a customer or other interested party playing a party role. A product is realized as one or more service(s) and / or resource(s). Product Inventory API performs the following operations on product : - Retrieval of a product or a collection of products depending on filter criteria - Partial update of a product (including updating rules and for administration purpose) - Creation of a product (including default values and creation rules and for administration purpose) - Deletion of a product (for administration purposes) - Notification of events on product. Copyright © TM Forum 2019. All Rights Reserved ") + + .version("4.0.0") + .license(new License().name("Apache 2.0").url("https://osl.etsi.org"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + + } + + +@Bean +public GroupedOpenApi pim637() { + + SpringDocUtils.getConfig().replaceWithClass(java.time.LocalDate.class, java.sql.Date.class); + SpringDocUtils.getConfig().replaceWithClass(java.time.OffsetDateTime.class, java.util.Date.class); + return GroupedOpenApi.builder() + .group("tmf-api-637-ProductInventoryManagement-v4.0.0") + .addOpenApiCustomizer( this.pim637penAPI() ) + .packagesToScan("org.etsi.osl.tmf.pim637.api") + .build(); + +} + /** * TMF 634 Resource Catalog Management @@ -183,7 +219,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -217,7 +253,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -255,7 +291,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -291,7 +327,7 @@ public class SwaggerDocumentationConfig { .version("2.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -328,7 +364,7 @@ public class SwaggerDocumentationConfig { .version("2.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -366,7 +402,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -403,7 +439,7 @@ public class SwaggerDocumentationConfig { .version("2.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -442,7 +478,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -479,7 +515,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -516,7 +552,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -555,7 +591,7 @@ public class SwaggerDocumentationConfig { // .version("3.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -594,7 +630,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -633,7 +669,7 @@ public class SwaggerDocumentationConfig { .version("1.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -671,7 +707,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -709,7 +745,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -744,7 +780,7 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("TMF API Tables") .url("https://www.tmforum.org/oda/open-apis/table")); @@ -781,10 +817,10 @@ public class SwaggerDocumentationConfig { .version("4.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("Openslice") - .url("http://openslice.io")); + .url("https://osl.etsi.org")); } @Bean @@ -826,10 +862,10 @@ public class SwaggerDocumentationConfig { .version("1.0.0") .license(new License() .name("Apache 2.0") - .url("http://openslice.io"))) + .url("https://osl.etsi.org"))) .externalDocs(new ExternalDocumentation() .description("Openslice") - .url("http://openslice.io")); + .url("https://osl.etsi.org")); } @Bean @@ -845,6 +881,72 @@ public class SwaggerDocumentationConfig { .build(); } + + /** + * TMF 628 Performance Management + * @return + */ + @Bean + public OpenApiCustomizer pm628OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF628 Performance Management API") + .description("TMF628 Performance Management API") + .version("5.0.0") + .license(new License() + .name("Apache 2.0") + .url("https://osl.etsi.org"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi pm628(){ + + SpringDocUtils.getConfig().replaceWithClass(java.time.LocalDate.class, java.sql.Date.class); + SpringDocUtils.getConfig().replaceWithClass(java.time.OffsetDateTime.class, java.util.Date.class); + return GroupedOpenApi.builder() + .group("tmf-api-628-PerformanceManagement-v5.0.0") + .addOpenApiCustomizer( this.pm628OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.pm628.api") + .build(); + + } + + /** + * TMF 702 Resource Activation Management + * @return + */ + @Bean + public OpenApiCustomizer ram7020penAPI() { + + + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 702 Resource Activation and Configuration") + .description("## TMF API Reference: TMF702 - Resource Activation \n\n### Release : 19.5 - December 2019\n\nResource Activation API goal is to provide the ability to activate Resources.\n\n### Operations\nResource Activation and Configuration API performs the following operations on the resources :\n- Retrieve an entity or a collection of entities depending on filter criteria\n- Partial update of an entity (including updating rules)\n- Create an entity (including default values and creation rules)\n- Delete an entity (for administration purposes)\n- Manage notification of events") + .version("4.0.0") + .license(new License().name("Apache 2.0").url("https://osl.etsi.org"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + + } + + + @Bean + public GroupedOpenApi ram702() { + + SpringDocUtils.getConfig().replaceWithClass(java.time.LocalDate.class, java.sql.Date.class); + SpringDocUtils.getConfig().replaceWithClass(java.time.OffsetDateTime.class, java.util.Date.class); + return GroupedOpenApi.builder() + .group("tmf-api-702-Resource Activation and Configuration-v4.0.0") + .addOpenApiCustomizer( this.ram7020penAPI() ) + .packagesToScan("org.etsi.osl.tmf.ram702.api") + .build(); + + } // @Bean diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApi.java index 3b0eacf57af62f8a30f4838f1fd8dd1f82d73742..181bde0b3086d73d27d6b74e7445740589dbbc74 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApi.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApi.java @@ -223,5 +223,25 @@ public interface ProductOfferingApi { } return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } + + @Operation(summary = "Creates and Retrieves a ProductOffering by ID", operationId = "retrieveProductOffering", description = "This operation retrieves a ProductOffering entity. Attribute selection is enabled for all first level attributes." , tags = { + "productOffering", }) + @ApiResponses(value = { @ApiResponse(responseCode ="200", description = "Success" ), + @ApiResponse(responseCode = "400", description = "Bad Request" ), + @ApiResponse(responseCode = "401", description = "Unauthorized" ), + @ApiResponse(responseCode = "403", description = "Forbidden" ), + @ApiResponse(responseCode = "404", description = "Not Found" ), + @ApiResponse(responseCode = "405", description = "Method Not allowed" ), + @ApiResponse(responseCode = "409", description = "Conflict" ), + @ApiResponse(responseCode = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/productOffering/fromServiceSpecId/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.POST) + default ResponseEntity<ProductOffering> createRetrieveProductOfferingBasedOnServiceSpec( + @Parameter(description = "Identifier of the ProductOffering", required = true) @PathVariable("id") String id) { + + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + } diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApiController.java index c22b53ea188f9f749058ba2d145b53ed8582501c..b13182529d12bee5dceadefb1d9ea62ae43a2a92 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApiController.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApiController.java @@ -166,6 +166,22 @@ public class ProductOfferingApiController implements ProductOfferingApi { return new ResponseEntity<ProductOffering>(HttpStatus.INTERNAL_SERVER_ERROR); } } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity<ProductOffering> createRetrieveProductOfferingBasedOnServiceSpec( + String id) { + try { + + + return new ResponseEntity<ProductOffering>(productOfferingRepoService.createRetrieveProductOfferingBasedOnServiceSpec(id), + HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<ProductOffering>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + } } diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..07fe723d0e242df176992fc1729001098dd3427e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java @@ -0,0 +1,95 @@ +package org.etsi.osl.tmf.pcm620.api; + +import org.apache.camel.LoggingLevel; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationUpdate; +import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingRepoService; +import org.etsi.osl.tmf.pcm620.reposervices.ProductSpecificationRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Configuration +//@RefreshScope +@Component +public class ProductSpecificationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ProductSpecificationApiRouteBuilder.class.getName()); + + @Value("${CATALOG_GET_PRODUCTSPEC_BY_ID}") + private String CATALOG_GET_PRODUCTSPEC_BY_ID = ""; + + + @Value("${CATALOG_ADD_PRODUCTSPEC}") + private String CATALOG_ADD_PRODUCTSPEC = ""; + + + @Value("${CATALOG_UPD_PRODUCTSPEC}") + private String CATALOG_UPD_PRODUCTSPEC = ""; + + @Value("${CATALOG_UPDADD_PRODUCTSPEC}") + private String CATALOG_UPDADD_PRODUCTSPEC = ""; + + + @Value("${CATALOG_GET_PRODUCTOFFERING_BY_ID}") + private String CATALOG_GET_PRODUCTOFFERING_BY_ID = ""; + + + + @Autowired + ProductSpecificationRepoService productSpecificationRepoService; + + @Autowired + ProductOfferingRepoService productOfferingRepoService; + + + @Override + public void configure() throws Exception { + from( CATALOG_GET_PRODUCTSPEC_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTSPEC_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( productSpecificationRepoService, "findByUuidEager") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + + from( CATALOG_ADD_PRODUCTSPEC ) + .log(LoggingLevel.INFO, log, CATALOG_ADD_PRODUCTSPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ProductSpecificationCreate .class, true) + .bean( productSpecificationRepoService, "addProductSpecification(${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPD_PRODUCTSPEC ) + .log(LoggingLevel.INFO, log, CATALOG_UPD_PRODUCTSPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ProductSpecificationUpdate.class, true) + .bean( productSpecificationRepoService, "updateProductSpecification(${header.serviceSpecId}, ${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPDADD_PRODUCTSPEC ) + .log(LoggingLevel.INFO, log, CATALOG_UPD_PRODUCTSPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ProductSpecificationUpdate.class, true) + .bean( productSpecificationRepoService, "updateOrAddProductSpecification(${header.serviceSpecId}, ${header.forceId}, ${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + + from( CATALOG_GET_PRODUCTOFFERING_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTOFFERING_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( productOfferingRepoService, "findByUuidEager") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java index b53dd5b0be6b91e419e748ff62d1583c3582dc58..40176d7b632d3795da8fa4b598a4fdfd4d25ea4c 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java @@ -26,21 +26,34 @@ import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import org.etsi.osl.tmf.JsonUtils; import org.etsi.osl.tmf.am651.model.AgreementRef; +import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.common.model.AttachmentRefOrValue; import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; import org.etsi.osl.tmf.pcm620.model.BundledProductOffering; import org.etsi.osl.tmf.pcm620.model.ProductOffering; import org.etsi.osl.tmf.pcm620.model.ProductOfferingCreate; import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceRef; import org.etsi.osl.tmf.pcm620.model.ProductOfferingUpdate; +import org.etsi.osl.tmf.pcm620.model.ProductSpecification; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristic; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristicValue; import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristicValueUse; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationRef; import org.etsi.osl.tmf.pcm620.repo.ProductOfferingRepository; +import org.etsi.osl.tmf.pcm620.repo.ProductSpecificationRepository; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -58,8 +71,12 @@ public class ProductOfferingRepoService { @Autowired ProductOfferingRepository prodsOfferingRepo; - - + + @Autowired + ProductSpecificationRepoService prodSpecRepoService; + + @Autowired + ServiceSpecificationRepoService serviceSpecificationRepoService; private SessionFactory sessionFactory; @@ -205,6 +222,8 @@ public class ProductOfferingRepoService { try { dd = session.get(ProductOffering.class, id); if (dd == null) { + tx.rollback(); + session.close(); return this.findByUuid(id);// last resort } Hibernate.initialize(dd.getAttachment()); @@ -221,6 +240,7 @@ public class ProductOfferingRepoService { Hibernate.initialize(dd.getProductOfferingTerm() ); Hibernate.initialize(dd.getServiceCandidate() ); Hibernate.initialize(dd.getResourceCandidate() ); + Hibernate.initialize(dd.getChannel()); tx.commit(); } finally { @@ -320,6 +340,7 @@ public class ProductOfferingRepoService { if ( prodOfferingUpd.getProductSpecification() != null ) { prodOffering.setProductSpecification( prodOfferingUpd.getProductSpecification() ); + prodOffering = copyCharacteristicsFromProdSpec( prodOffering, prodOfferingUpd.getProductSpecification() ); } @@ -542,5 +563,74 @@ public class ProductOfferingRepoService { return prodOffering; } + + private ProductOffering copyCharacteristicsFromProdSpec(ProductOffering prodOffering, + @Valid ProductSpecificationRef productSpecRef) { + + ProductSpecification prodSpec = prodSpecRepoService.findByUuid( productSpecRef.getId() ); + + if (prodSpec!= null ) { + for (ProductSpecificationCharacteristic prodSpecChar : prodSpec.getProductSpecCharacteristic()) { + if ( prodOffering.findCharacteristicByName( prodSpecChar.getName() ) == null ) { + ProductSpecificationCharacteristicValueUse pcitem = new ProductSpecificationCharacteristicValueUse(); + pcitem.name( prodSpecChar.getName() ); + pcitem.setDescription(prodSpecChar.getDescription()); + pcitem + .maxCardinality(prodSpecChar.getMaxCardinality()) + .minCardinality(prodSpecChar.getMinCardinality()) + .valueType(prodSpecChar.getValueType()); + + for (ProductSpecificationCharacteristicValue r : prodSpecChar.getProductSpecCharacteristicValue()) { + ProductSpecificationCharacteristicValue pcval = new ProductSpecificationCharacteristicValue(); + pcval.isDefault(r.isIsDefault()) + .rangeInterval(r.getRangeInterval()) + .regex(r.getRegex()) + .unitOfMeasure(r.getUnitOfMeasure()) + .valueFrom(r.getValueFrom()+"") + .valueTo(r.getValueTo()+"") + .valueType(r.getValueType()) + .value( new Any( r.getValue() ) ); + pcitem.addProductSpecCharacteristicValueItem( pcval ); + + } + + + prodOffering.addProdSpecCharValueUseItem(pcitem ); + } + } + } + + return prodOffering; + } + + public ProductOffering createRetrieveProductOfferingBasedOnServiceSpec(String id) { + + ServiceSpecification serviceSpec = serviceSpecificationRepoService.findByUuid(id); + ProductSpecificationCreate psc = new ProductSpecificationCreate(); + psc.setName(serviceSpec.getName()); + psc.setDescription(serviceSpec.getDescription()); + + ProductSpecification responseProdSpec = prodSpecRepoService.addProductSpecification(psc); + + responseProdSpec = prodSpecRepoService.addServiceSpecToProductSpec( responseProdSpec, serviceSpec ); + + ProductOffering pOffer = this.prodOfferingFromPrdSpec( responseProdSpec ); + + return pOffer; + } + + private ProductOffering prodOfferingFromPrdSpec(ProductSpecification responseProdSpec) { + ProductSpecificationRef prodSpecRef = new ProductSpecificationRef(); + prodSpecRef.setId(responseProdSpec.getId()); + prodSpecRef.setName(responseProdSpec.getName()); + + ProductOfferingCreate pefCre = new ProductOfferingCreate(); + pefCre.setName( responseProdSpec.getName()); + pefCre.productSpecification(prodSpecRef); + + ProductOffering pOffer = this.addProductOffering(pefCre); + + return pOffer; + } } diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductSpecificationRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductSpecificationRepoService.java index 2994b2aea69a05b52b4309ccf9da950156f8cdd2..deec0a663436f017e7d66f89389fb22bd6cd8ea6 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductSpecificationRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductSpecificationRepoService.java @@ -30,6 +30,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.common.model.AttachmentRefOrValue; import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.TimePeriod; @@ -37,12 +38,17 @@ import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; import org.etsi.osl.tmf.pcm620.model.BundledProductSpecification; import org.etsi.osl.tmf.pcm620.model.ProductSpecification; import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristic; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristicValue; import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate; import org.etsi.osl.tmf.pcm620.model.ProductSpecificationRelationship; import org.etsi.osl.tmf.pcm620.model.ProductSpecificationUpdate; import org.etsi.osl.tmf.pcm620.repo.ProductSpecificationRepository; import org.etsi.osl.tmf.prm669.model.RelatedParty; import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -61,7 +67,9 @@ public class ProductSpecificationRepoService { @Autowired ProductSpecificationRepository prodsOfferingRepo; - + + @Autowired + ServiceSpecificationRepoService serviceSpecificationRepoService; private SessionFactory sessionFactory; @@ -200,6 +208,8 @@ public class ProductSpecificationRepoService { return optionalCat.orElse(null); } + + @Transactional public ProductSpecification findByUuidEager(String id) { Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? @@ -207,16 +217,18 @@ public class ProductSpecificationRepoService { try { dd = session.get(ProductSpecification.class, id); if (dd == null) { + session.close(); return this.findByUuid(id);// last resort } Hibernate.initialize(dd.getAttachment()); Hibernate.initialize(dd.getRelatedParty() ); Hibernate.initialize(dd.getBundledProductSpecification() ); Hibernate.initialize(dd.getResourceSpecification() ); - Hibernate.initialize(dd.getServiceSpecification() ); + Hibernate.initialize(dd.getServiceSpecification() ); + Hibernate.initialize(dd.getProductSpecificationRelationship() ); for (ProductSpecificationCharacteristic schar : dd.getProductSpecCharacteristic() ) { Hibernate.initialize(schar.getProductSpecCharacteristicValue() ); - + Hibernate.initialize(schar.getProductSpecCharRelationship() ); } @@ -428,7 +440,7 @@ public class ProductSpecificationRepoService { } - + /** * Update ProductSpecificationRelationship list @@ -548,7 +560,7 @@ public class ProductSpecificationRepoService { } /** - * Update ResourceSpecificationRef list + * Update ServiceSpecificationRef list */ if (prodSpecUpd.getServiceSpecification() != null) { @@ -569,6 +581,7 @@ public class ProductSpecificationRepoService { if (!idexists) { prodSpec.getServiceSpecification().add(ar); + prodSpec = copyConfigurableCharacteristics( prodSpec, ar ); idAddedUpdated.put(ar.getUuid(), true); } } @@ -597,5 +610,74 @@ public class ProductSpecificationRepoService { return prodSpec; } + + private ProductSpecification copyConfigurableCharacteristics(ProductSpecification prodSpec, + ServiceSpecificationRef ar) { + + ServiceSpecification sourceSpec = serviceSpecificationRepoService.findByUuid(ar.getId()); + + if ( sourceSpec != null ) { + for (ServiceSpecCharacteristic ssc : sourceSpec.getServiceSpecCharacteristic()) { + if (ssc.isConfigurable()!= null && ssc.isConfigurable()) { + if ( prodSpec.findProdCharacteristicByName( ssc.getName() ) == null ) { + + ProductSpecificationCharacteristic cnew = new ProductSpecificationCharacteristic(); + cnew.setName( ssc.getName() ); + cnew.setDescription( ssc.getDescription()); + cnew.isUnique(ssc.isIsUnique()) + .extensible(ssc.isExtensible()) + .maxCardinality(ssc.getMaxCardinality()) + .minCardinality(ssc.getMinCardinality()) + .valueType(ssc.getValueType()); + for (ServiceSpecCharacteristicValue r : ssc.getServiceSpecCharacteristicValue()) { + ProductSpecificationCharacteristicValue pcval = new ProductSpecificationCharacteristicValue(); + pcval.isDefault(r.isIsDefault()) + .rangeInterval(r.getRangeInterval()) + .regex(r.getRegex()) + .unitOfMeasure(r.getUnitOfMeasure()) + .valueFrom(r.getValueFrom()+"") + .valueTo(r.getValueTo()+"") + .valueType(r.getValueType()) + .value( new Any( r.getValue() ) ); + + cnew.addProductSpecCharacteristicValueItem( pcval ); + } + + prodSpec.getProductSpecCharacteristic().add( cnew ); + + } + } + } + } + + return prodSpec; + } + + public ProductSpecification addServiceSpecToProductSpec(ProductSpecification responseProdSpec, ServiceSpecification serviceSpec) { + + ServiceSpecificationRef serviceSpecRef = new ServiceSpecificationRef(); + serviceSpecRef.setId( serviceSpec.getId() ); + serviceSpecRef.setName( serviceSpec.getName()); + serviceSpecRef.setVersion(serviceSpec.getVersion()); + serviceSpecRef.setReferredType(serviceSpec.getType()); + + ProductSpecificationUpdate pSpecUpd = new ProductSpecificationUpdate(); + pSpecUpd.addServiceSpecificationItem(serviceSpecRef); + if (responseProdSpec.getServiceSpecification()!=null) { + pSpecUpd.getServiceSpecification().addAll( responseProdSpec.getServiceSpecification() ); + } + responseProdSpec = updateProductSpecificationDataFromAPIcall(responseProdSpec, pSpecUpd); + + return responseProdSpec; + } + + public ProductSpecification updateOrAddProductSpecification(String id, ProductSpecificationCreate productSpecificatioCreate) { + ProductSpecification serviceSpec = updateProductSpecification(id, productSpecificatioCreate ); + if ( serviceSpec == null ) { + serviceSpec = addProductSpecification( productSpecificatioCreate ); + } + + return serviceSpec; + } } diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/pim637/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..dee19e45a7d626efd22887db321cb5555cd9171d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/ApiException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.pim637.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +public class ApiException extends Exception { + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/pim637/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..653abc4129136c306030c9b2be54c6034155496c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/ApiOriginFilter.java @@ -0,0 +1,30 @@ +package org.etsi.osl.tmf.pim637.api; + +import java.io.IOException; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +public class ApiOriginFilter implements jakarta.servlet.Filter { + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/pim637/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..8bf7d4c83b4b574be35b1356da5e528e47354956 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package org.etsi.osl.tmf.pim637.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +@jakarta.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/pim637/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..7dc3b86aea3df45469e25725451605e52133e6c8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/HubApi.java @@ -0,0 +1,77 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.60). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pim637.api; + +import org.etsi.osl.tmf.pim637.model.Error; +import org.etsi.osl.tmf.pim637.model.EventSubscription; +import org.etsi.osl.tmf.pim637.model.EventSubscriptionInput; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +@Validated +public interface HubApi { + + @Operation(summary = "Register a listener", description = "Sets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics.", tags={ "events subscription" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Subscribed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity<EventSubscription> registerListener(@Parameter(in = ParameterIn.DEFAULT, description = "Data containing the callback endpoint to deliver the information", required=true, schema=@Schema()) @Valid @RequestBody EventSubscriptionInput body +); + + + @Operation(summary = "Unregister a listener", description = "Resets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics.", tags={ "events subscription" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "204", description = "Deleted"), + + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity<Void> unregisterListener(@Parameter(in = ParameterIn.PATH, description = "The id of the registered listener", required=true, schema=@Schema()) @PathVariable("id") String id +); + +} + diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/pim637/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..96129c8d13131e6c601ca1a826feaff0434177e2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/HubApiController.java @@ -0,0 +1,57 @@ +package org.etsi.osl.tmf.pim637.api; + +import java.io.IOException; +import jakarta.servlet.http.HttpServletRequest; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pim637.model.EventSubscription; +import org.etsi.osl.tmf.pim637.model.EventSubscriptionInput; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +@RestController("HubApiController637") +public class HubApiController implements HubApi { + + private static final Logger log = LoggerFactory.getLogger(HubApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public HubApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + public ResponseEntity<EventSubscription> registerListener(@Parameter(in = ParameterIn.DEFAULT, description = "Data containing the callback endpoint to deliver the information", required=true, schema=@Schema()) @Valid @RequestBody EventSubscriptionInput body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<EventSubscription>(objectMapper.readValue("{\r\n \"query\" : \"query\",\r\n \"callback\" : \"callback\",\r\n \"id\" : \"id\"\r\n}", EventSubscription.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<EventSubscription>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<EventSubscription>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<Void> unregisterListener(@Parameter(in = ParameterIn.PATH, description = "The id of the registered listener", required=true, schema=@Schema()) @PathVariable("id") String id +) { + String accept = request.getHeader("Accept"); + return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..8ea75df1e1c1685af62bef92deb90df4eee25ce9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApi.java @@ -0,0 +1,158 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.60). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pim637.api; + +import org.etsi.osl.tmf.pim637.model.Error; +import org.etsi.osl.tmf.pim637.model.EventSubscription; +import org.etsi.osl.tmf.pim637.model.ProductAttributeValueChangeEvent; +import org.etsi.osl.tmf.pim637.model.ProductBatchEvent; +import org.etsi.osl.tmf.pim637.model.ProductCreateEvent; +import org.etsi.osl.tmf.pim637.model.ProductDeleteEvent; +import org.etsi.osl.tmf.pim637.model.ProductStateChangeEvent; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +@Validated +public interface ListenerApi { + + @Operation(summary = "Client listener for entity ProductAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ProductAttributeValueChangeEvent", tags={ "notification listeners (client side)" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Notified", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/listener/productAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity<EventSubscription> listenToProductAttributeValueChangeEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductAttributeValueChangeEvent body +); + + + @Operation(summary = "Client listener for entity ProductBatchEvent", description = "Example of a client listener for receiving the notification ProductBatchEvent", tags={ "notification listeners (client side)" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Notified", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/listener/productBatchEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity<EventSubscription> listenToProductBatchEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductBatchEvent body +); + + + @Operation(summary = "Client listener for entity ProductCreateEvent", description = "Example of a client listener for receiving the notification ProductCreateEvent", tags={ "notification listeners (client side)" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Notified", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/listener/productCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity<EventSubscription> listenToProductCreateEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductCreateEvent body +); + + + @Operation(summary = "Client listener for entity ProductDeleteEvent", description = "Example of a client listener for receiving the notification ProductDeleteEvent", tags={ "notification listeners (client side)" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Notified", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/listener/productDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity<EventSubscription> listenToProductDeleteEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductDeleteEvent body +); + + + @Operation(summary = "Client listener for entity ProductStateChangeEvent", description = "Example of a client listener for receiving the notification ProductStateChangeEvent", tags={ "notification listeners (client side)" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Notified", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/listener/productStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity<EventSubscription> listenToProductStateChangeEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductStateChangeEvent body +); + +} + diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..475d90f202574fa8d31ad7501d7cffd439007ba4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApiController.java @@ -0,0 +1,117 @@ +package org.etsi.osl.tmf.pim637.api; + +import java.io.IOException; +import jakarta.servlet.http.HttpServletRequest; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pim637.model.EventSubscription; +import org.etsi.osl.tmf.pim637.model.ProductAttributeValueChangeEvent; +import org.etsi.osl.tmf.pim637.model.ProductBatchEvent; +import org.etsi.osl.tmf.pim637.model.ProductCreateEvent; +import org.etsi.osl.tmf.pim637.model.ProductDeleteEvent; +import org.etsi.osl.tmf.pim637.model.ProductStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +@Controller("ListenerApiController637") +@RequestMapping("/productInventoryManagement/v4/") +public class ListenerApiController implements ListenerApi { + + private static final Logger log = LoggerFactory.getLogger(ListenerApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ListenerApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + public ResponseEntity<EventSubscription> listenToProductAttributeValueChangeEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductAttributeValueChangeEvent body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<EventSubscription>(objectMapper.readValue("{\r\n \"query\" : \"query\",\r\n \"callback\" : \"callback\",\r\n \"id\" : \"id\"\r\n}", EventSubscription.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<EventSubscription>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<EventSubscription>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<EventSubscription> listenToProductBatchEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductBatchEvent body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<EventSubscription>(objectMapper.readValue("{\r\n \"query\" : \"query\",\r\n \"callback\" : \"callback\",\r\n \"id\" : \"id\"\r\n}", EventSubscription.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<EventSubscription>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<EventSubscription>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<EventSubscription> listenToProductCreateEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductCreateEvent body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<EventSubscription>(objectMapper.readValue("{\r\n \"query\" : \"query\",\r\n \"callback\" : \"callback\",\r\n \"id\" : \"id\"\r\n}", EventSubscription.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<EventSubscription>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<EventSubscription>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<EventSubscription> listenToProductDeleteEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductDeleteEvent body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<EventSubscription>(objectMapper.readValue("{\r\n \"query\" : \"query\",\r\n \"callback\" : \"callback\",\r\n \"id\" : \"id\"\r\n}", EventSubscription.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<EventSubscription>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<EventSubscription>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<EventSubscription> listenToProductStateChangeEvent(@Parameter(in = ParameterIn.DEFAULT, description = "The event data", required=true, schema=@Schema()) @Valid @RequestBody ProductStateChangeEvent body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<EventSubscription>(objectMapper.readValue("{\r\n \"query\" : \"query\",\r\n \"callback\" : \"callback\",\r\n \"id\" : \"id\"\r\n}", EventSubscription.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<EventSubscription>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<EventSubscription>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/pim637/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..37767fee4433b2d43cb050541511b68b07971f28 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/NotFoundException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.pim637.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/ProductApi.java b/src/main/java/org/etsi/osl/tmf/pim637/api/ProductApi.java new file mode 100644 index 0000000000000000000000000000000000000000..c4f9f782563f7131a31f0a781f030f7310203880 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/ProductApi.java @@ -0,0 +1,158 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.60). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pim637.api; + +import java.util.List; +import org.etsi.osl.tmf.pim637.model.Error; +import org.etsi.osl.tmf.pim637.model.Product; +import org.etsi.osl.tmf.pim637.model.ProductCreate; +import org.etsi.osl.tmf.pim637.model.ProductUpdate; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +@Validated +public interface ProductApi { + + @Operation(summary = "Creates a Product", description = "This operation creates a Product entity.", tags={ "product" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Product.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/product", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity<Product> createProduct(@Parameter(in = ParameterIn.DEFAULT, description = "The Product to be created", required=true, schema=@Schema()) @Valid @RequestBody ProductCreate body +); + + + @Operation(summary = "Deletes a Product", description = "This operation deletes a Product entity.", tags={ "product" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "204", description = "Deleted"), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/product/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity<Void> deleteProduct(@Parameter(in = ParameterIn.PATH, description = "Identifier of the Product", required=true, schema=@Schema()) @PathVariable("id") String id +); + + + @Operation(summary = "List or find Product objects", description = "This operation list or find Product entities", tags={ "product" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success", content = @Content(mediaType = "application/json;charset=utf-8", array = @ArraySchema(schema = @Schema(implementation = Product.class)))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/product", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity<List<Product>> listProduct(@Parameter(in = ParameterIn.QUERY, description = "Comma-separated properties to be provided in response" ,schema=@Schema()) @Valid @RequestParam(value = "fields", required = false) String fields +, @Parameter(in = ParameterIn.QUERY, description = "Requested index for start of resources to be provided in response" ,schema=@Schema()) @Valid @RequestParam(value = "offset", required = false) Integer offset +, @Parameter(in = ParameterIn.QUERY, description = "Requested number of resources to be provided in response" ,schema=@Schema()) @Valid @RequestParam(value = "limit", required = false) Integer limit +); + + + @Operation(summary = "Updates partially a Product", description = "This operation updates partially a Product entity.", tags={ "product" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Updated", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Product.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/product/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + ResponseEntity<Product> patchProduct(@Parameter(in = ParameterIn.PATH, description = "Identifier of the Product", required=true, schema=@Schema()) @PathVariable("id") String id +, @Parameter(in = ParameterIn.DEFAULT, description = "The Product to be updated", required=true, schema=@Schema()) @Valid @RequestBody ProductUpdate body +); + + + @Operation(summary = "Retrieves a Product by ID", description = "This operation retrieves a Product entity. Attribute selection is enabled for all first level attributes.", tags={ "product" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Product.class))), + + @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "409", description = "Conflict", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))), + + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class))) }) + @RequestMapping(value = "/product/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity<Product> retrieveProduct(@Parameter(in = ParameterIn.PATH, description = "Identifier of the Product", required=true, schema=@Schema()) @PathVariable("id") String id +, @Parameter(in = ParameterIn.QUERY, description = "Comma-separated properties to provide in response" ,schema=@Schema()) @Valid @RequestParam(value = "fields", required = false) String fields +); + +} + diff --git a/src/main/java/org/etsi/osl/tmf/pim637/api/ProductApiController.java b/src/main/java/org/etsi/osl/tmf/pim637/api/ProductApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..f53ce22c4fc59e9cdaed8f3c80768cbf5be5f626 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/ProductApiController.java @@ -0,0 +1,112 @@ +package org.etsi.osl.tmf.pim637.api; + +import java.io.IOException; +import java.util.List; +import jakarta.servlet.http.HttpServletRequest; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pim637.model.Product; +import org.etsi.osl.tmf.pim637.model.ProductCreate; +import org.etsi.osl.tmf.pim637.model.ProductUpdate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-08-04T00:27:07.324017400+03:00[Europe/Athens]") +@Controller("productApiController637") +@RequestMapping("/productInventoryManagement/v4/") +public class ProductApiController implements ProductApi { + + private static final Logger log = LoggerFactory.getLogger(ProductApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ProductApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + public ResponseEntity<Product> createProduct(@Parameter(in = ParameterIn.DEFAULT, description = "The Product to be created", required=true, schema=@Schema()) @Valid @RequestBody ProductCreate body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<Product>(objectMapper.readValue("{\r\n \"isBundle\" : true,\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ null, null ],\r\n \"description\" : \"description\",\r\n \"billingAccount\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"realizingService\" : [ null, null ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n }, {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n } ],\r\n \"agreement\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n } ],\r\n \"productTerm\" : [ null, null ],\r\n \"relatedParty\" : [ null, null ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ null, null ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ null, null ]\r\n}", Product.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Product>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<Product>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<Void> deleteProduct(@Parameter(in = ParameterIn.PATH, description = "Identifier of the Product", required=true, schema=@Schema()) @PathVariable("id") String id +) { + String accept = request.getHeader("Accept"); + return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<List<Product>> listProduct(@Parameter(in = ParameterIn.QUERY, description = "Comma-separated properties to be provided in response" ,schema=@Schema()) @Valid @RequestParam(value = "fields", required = false) String fields +,@Parameter(in = ParameterIn.QUERY, description = "Requested index for start of resources to be provided in response" ,schema=@Schema()) @Valid @RequestParam(value = "offset", required = false) Integer offset +,@Parameter(in = ParameterIn.QUERY, description = "Requested number of resources to be provided in response" ,schema=@Schema()) @Valid @RequestParam(value = "limit", required = false) Integer limit +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<List<Product>>(objectMapper.readValue("[ {\r\n \"isBundle\" : true,\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ null, null ],\r\n \"description\" : \"description\",\r\n \"billingAccount\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"realizingService\" : [ null, null ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n }, {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n } ],\r\n \"agreement\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n } ],\r\n \"productTerm\" : [ null, null ],\r\n \"relatedParty\" : [ null, null ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ null, null ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ null, null ]\r\n}, {\r\n \"isBundle\" : true,\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ null, null ],\r\n \"description\" : \"description\",\r\n \"billingAccount\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"realizingService\" : [ null, null ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n }, {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n } ],\r\n \"agreement\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n } ],\r\n \"productTerm\" : [ null, null ],\r\n \"relatedParty\" : [ null, null ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ null, null ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ null, null ]\r\n} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<List<Product>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<List<Product>>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<Product> patchProduct(@Parameter(in = ParameterIn.PATH, description = "Identifier of the Product", required=true, schema=@Schema()) @PathVariable("id") String id +,@Parameter(in = ParameterIn.DEFAULT, description = "The Product to be updated", required=true, schema=@Schema()) @Valid @RequestBody ProductUpdate body +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<Product>(objectMapper.readValue("{\r\n \"isBundle\" : true,\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ null, null ],\r\n \"description\" : \"description\",\r\n \"billingAccount\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"realizingService\" : [ null, null ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n }, {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n } ],\r\n \"agreement\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n } ],\r\n \"productTerm\" : [ null, null ],\r\n \"relatedParty\" : [ null, null ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ null, null ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ null, null ]\r\n}", Product.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Product>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<Product>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity<Product> retrieveProduct(@Parameter(in = ParameterIn.PATH, description = "Identifier of the Product", required=true, schema=@Schema()) @PathVariable("id") String id +,@Parameter(in = ParameterIn.QUERY, description = "Comma-separated properties to provide in response" ,schema=@Schema()) @Valid @RequestParam(value = "fields", required = false) String fields +) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity<Product>(objectMapper.readValue("{\r\n \"isBundle\" : true,\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ null, null ],\r\n \"description\" : \"description\",\r\n \"billingAccount\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"realizingService\" : [ null, null ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n }, {\r\n \"isBundle\" : true,\r\n \"productSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"targetProductSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"@referredType\" : \"@referredType\",\r\n \"@type\" : \"@type\",\r\n \"productCharacteristic\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { }\r\n } ],\r\n \"description\" : \"description\",\r\n \"productOrderItem\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"productOrderHref\" : \"productOrderHref\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItemId\" : \"orderItemId\",\r\n \"@type\" : \"@type\",\r\n \"productOrderId\" : \"productOrderId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderItemAction\" : \"orderItemAction\"\r\n } ],\r\n \"realizingService\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"terminationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"realizingResource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"place\" : [ null, null ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"product\" : [ null, null ],\r\n \"agreement\" : [ null, null ],\r\n \"productOffering\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"duration\" : {\r\n \"amount\" : 2.302136,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : {\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"relatedParty\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n }, {\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"price\" : {\r\n \"taxRate\" : 6.0274563,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"percentage\" : 0.8008282,\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"dutyFreeAmount\" : {\r\n \"unit\" : \"unit\",\r\n \"value\" : 1.4658129\r\n }\r\n },\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"productOfferingPrice\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"applicationDuration\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"status\" : \"created\"\r\n } ],\r\n \"agreement\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"agreementItemId\" : \"agreementItemId\"\r\n } ],\r\n \"productTerm\" : [ null, null ],\r\n \"relatedParty\" : [ null, null ],\r\n \"productSerialNumber\" : \"productSerialNumber\",\r\n \"name\" : \"name\",\r\n \"productRelationship\" : [ null, null ],\r\n \"isCustomerVisible\" : true,\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"productPrice\" : [ null, null ]\r\n}", Product.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Product>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<Product>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/README.md b/src/main/java/org/etsi/osl/tmf/pm628/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5cd22b6081a211257f7ea2e6b0bef98c47926b4f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/README.md @@ -0,0 +1,21 @@ +# OpenAPI generated server + +Spring Boot Server + +## Overview +This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. +This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. + + +The underlying library integrating OpenAPI to Spring Boot is [springdoc](https://springdoc.org). +Springdoc will generate an OpenAPI v3 specification based on the generated Controller and Model classes. +The specification is available to download using the following url: +http://localhost:8080/v3/api-docs/ + +Start your server as a simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:8080/swagger-ui.html + +Change default port value in application.properties \ No newline at end of file diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/ApiUtil.java b/src/main/java/org/etsi/osl/tmf/pm628/api/ApiUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..0ad52b68062b71420fadbdf6c7400f4c7d9e1c51 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/ApiUtil.java @@ -0,0 +1,19 @@ +package org.etsi.osl.tmf.pm628.api; + +import org.springframework.web.context.request.NativeWebRequest; + +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class ApiUtil { + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class); + res.setCharacterEncoding("UTF-8"); + res.addHeader("Content-Type", contentType); + res.getWriter().print(example); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApi.java new file mode 100644 index 0000000000000000000000000000000000000000..147ee55d5070f6e526f3a20f4a3c4c4c6df68cef --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApi.java @@ -0,0 +1,273 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.pm628.model.DataAccessEndpoint; +import org.etsi.osl.tmf.common.model.Error; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "dataAccessEndpoint", description = "Operations for DataAccessEndpoint Resource") +public interface DataAccessEndpointApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * GET /dataAccessEndpoint : List or find DataAccessEndpoint objects + * List or find DataAccessEndpoint objects + * + * @param fields Comma-separated properties to be provided in response (optional) + * @param offset Requested index for start of resources to be provided in response (optional) + * @param limit Requested number of resources to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "listDataAccessEndpoint", + summary = "List or find DataAccessEndpoint objects", + description = "List or find DataAccessEndpoint objects", + tags = { "dataAccessEndpoint" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = DataAccessEndpoint.class))) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/dataAccessEndpoint", + produces = { "application/json" } + ) + + default ResponseEntity<List<DataAccessEndpoint>> listDataAccessEndpoint( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "[ { \"uriQueryFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"uri\" : \"https://openapi-generator.tech\", \"apiType\" : \"apiType\" }, { \"uriQueryFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"uri\" : \"https://openapi-generator.tech\", \"apiType\" : \"apiType\" } ]"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /dataAccessEndpoint/{id} : Retrieves a DataAccessEndpoint by ID + * This operation retrieves a DataAccessEndpoint entity. Attribute selection enabled for all first level attributes. + * + * @param id Identifier of the Resource (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "retrieveDataAccessEndpoint", + summary = "Retrieves a DataAccessEndpoint by ID", + description = "This operation retrieves a DataAccessEndpoint entity. Attribute selection enabled for all first level attributes.", + tags = { "dataAccessEndpoint" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = DataAccessEndpoint.class)) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/dataAccessEndpoint/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<DataAccessEndpoint> retrieveDataAccessEndpoint( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"uriQueryFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"uri\" : \"https://openapi-generator.tech\", \"apiType\" : \"apiType\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..13598a5e50a7bcda639b85536eaac6ebac0f80b0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApiController.java @@ -0,0 +1,75 @@ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.pm628.model.DataAccessEndpoint; +import org.etsi.osl.tmf.pm628.reposervices.DataAccessEndpointService; +import org.etsi.osl.tmf.pm628.api.DataAccessEndpointApiController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller +@RequestMapping("/performance/v5") +public class DataAccessEndpointApiController implements DataAccessEndpointApi { + + private static final Logger log = LoggerFactory.getLogger(DataAccessEndpointApiController.class); + + private final NativeWebRequest request; + + @Autowired + DataAccessEndpointService dataAccessEndpointService; + + @Autowired + public DataAccessEndpointApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<List<DataAccessEndpoint>> listDataAccessEndpoint( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + try { + return new ResponseEntity<List<DataAccessEndpoint>>(dataAccessEndpointService.findAllDataAccessEndpoints(), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<List<DataAccessEndpoint>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<DataAccessEndpoint> retrieveDataAccessEndpoint( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + try { + return new ResponseEntity<DataAccessEndpoint>(dataAccessEndpointService.findDataAccessEndpointByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<DataAccessEndpoint>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..c9c67a58a25d0bbebd25b8f134dab66036b4ff98 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/HubApi.java @@ -0,0 +1,134 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.common.model.Error; +import org.etsi.osl.tmf.pm628.model.Hub; +import org.etsi.osl.tmf.pm628.model.HubFVO; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "events subscription", description = "Endpoints to register and terminate an Event Listener") +public interface HubApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * POST /hub : Create a subscription (hub) to receive Events + * Sets the communication endpoint to receive Events. + * + * @param hubFVO Data containing the callback endpoint to deliver the information (required) + * @return Notified (status code 201) + * or Error (status code 200) + */ + @Operation( + operationId = "createHub", + summary = "Create a subscription (hub) to receive Events", + description = "Sets the communication endpoint to receive Events.", + tags = { "events subscription" }, + responses = { + @ApiResponse(responseCode = "201", description = "Notified", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Hub.class)) + }), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/hub", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Hub> createHub( + @Parameter(name = "HubFVO", description = "Data containing the callback endpoint to deliver the information", required = true) @Valid @RequestBody HubFVO hubFVO + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /hub/{id} : Remove a subscription (hub) to receive Events + * + * + * @param id Identifier of the Resource (required) + * @return Deleted (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "hubDelete", + summary = "Remove a subscription (hub) to receive Events", + description = "", + tags = { "events subscription" }, + responses = { + @ApiResponse(responseCode = "204", description = "Deleted"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/hub/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<Void> hubDelete( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..c3bf28d4f446c20dbb3f7860792c146e14fae6d4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/HubApiController.java @@ -0,0 +1,28 @@ +package org.etsi.osl.tmf.pm628.api; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller("HubApiController628") +@RequestMapping("/performance/v5") +public class HubApiController implements HubApi { + + private final NativeWebRequest request; + + @Autowired + public HubApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..3ead3a97687ff776d7fc9208cda9b20477500cb7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApi.java @@ -0,0 +1,389 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.common.model.Error; +import org.etsi.osl.tmf.pm628.model.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "notification listener", description = "Notifications for Resource Lifecycle and event notifications") +public interface ListenerApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * POST /listener/measurementCollectionJobAttributeValueChangeEvent : Client listener for entity MeasurementCollectionJobAttributeValueChangeEvent + * Example of a client listener for receiving the notification MeasurementCollectionJobAttributeValueChangeEvent + * + * @param measurementCollectionJobAttributeValueChangeEvent MeasurementCollectionJob attributeValueChange Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "measurementCollectionJobAttributeValueChangeEvent", + summary = "Client listener for entity MeasurementCollectionJobAttributeValueChangeEvent", + description = "Example of a client listener for receiving the notification MeasurementCollectionJobAttributeValueChangeEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/measurementCollectionJobAttributeValueChangeEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> measurementCollectionJobAttributeValueChangeEvent( + @Parameter(name = "MeasurementCollectionJobAttributeValueChangeEvent", description = "MeasurementCollectionJob attributeValueChange Event payload", required = true) @Valid @RequestBody MeasurementCollectionJobAttributeValueChangeEvent measurementCollectionJobAttributeValueChangeEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /listener/measurementCollectionJobCreateEvent : Client listener for entity MeasurementCollectionJobCreateEvent + * Example of a client listener for receiving the notification MeasurementCollectionJobCreateEvent + * + * @param measurementCollectionJobCreateEvent MeasurementCollectionJob create Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "measurementCollectionJobCreateEvent", + summary = "Client listener for entity MeasurementCollectionJobCreateEvent", + description = "Example of a client listener for receiving the notification MeasurementCollectionJobCreateEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/measurementCollectionJobCreateEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> measurementCollectionJobCreateEvent( + @Parameter(name = "MeasurementCollectionJobCreateEvent", description = "MeasurementCollectionJob create Event payload", required = true) @Valid @RequestBody MeasurementCollectionJobCreateEvent measurementCollectionJobCreateEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /listener/measurementCollectionJobDeleteEvent : Client listener for entity MeasurementCollectionJobDeleteEvent + * Example of a client listener for receiving the notification MeasurementCollectionJobDeleteEvent + * + * @param measurementCollectionJobDeleteEvent MeasurementCollectionJob delete Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "measurementCollectionJobDeleteEvent", + summary = "Client listener for entity MeasurementCollectionJobDeleteEvent", + description = "Example of a client listener for receiving the notification MeasurementCollectionJobDeleteEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/measurementCollectionJobDeleteEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> measurementCollectionJobDeleteEvent( + @Parameter(name = "MeasurementCollectionJobDeleteEvent", description = "MeasurementCollectionJob delete Event payload", required = true) @Valid @RequestBody MeasurementCollectionJobDeleteEvent measurementCollectionJobDeleteEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /listener/measurementCollectionJobExecutionStateChangeEvent : Client listener for entity MeasurementCollectionJobExecutionStateChangeEvent + * Example of a client listener for receiving the notification MeasurementCollectionJobExecutionStateChangeEvent + * + * @param measurementCollectionJobExecutionStateChangeEvent MeasurementCollectionJob executionStateChange Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "measurementCollectionJobExecutionStateChangeEvent", + summary = "Client listener for entity MeasurementCollectionJobExecutionStateChangeEvent", + description = "Example of a client listener for receiving the notification MeasurementCollectionJobExecutionStateChangeEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/measurementCollectionJobExecutionStateChangeEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> measurementCollectionJobExecutionStateChangeEvent( + @Parameter(name = "MeasurementCollectionJobExecutionStateChangeEvent", description = "MeasurementCollectionJob executionStateChange Event payload", required = true) @Valid @RequestBody MeasurementCollectionJobExecutionStateChangeEvent measurementCollectionJobExecutionStateChangeEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /listener/measurementCollectionJobFilesPreparationErrorEvent : Client listener for entity MeasurementCollectionJobFilesPreparationErrorEvent + * Example of a client listener for receiving the notification MeasurementCollectionJobFilesPreparationErrorEvent + * + * @param measurementCollectionJobFilesPreparationErrorEvent MeasurementCollectionJob filesPreparationError Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "measurementCollectionJobFilesPreparationErrorEvent", + summary = "Client listener for entity MeasurementCollectionJobFilesPreparationErrorEvent", + description = "Example of a client listener for receiving the notification MeasurementCollectionJobFilesPreparationErrorEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/measurementCollectionJobFilesPreparationErrorEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> measurementCollectionJobFilesPreparationErrorEvent( + @Parameter(name = "MeasurementCollectionJobFilesPreparationErrorEvent", description = "MeasurementCollectionJob filesPreparationError Event payload", required = true) @Valid @RequestBody MeasurementCollectionJobFilesPreparationErrorEvent measurementCollectionJobFilesPreparationErrorEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /listener/measurementCollectionJobFilesReadyEvent : Client listener for entity MeasurementCollectionJobFilesReadyEvent + * Example of a client listener for receiving the notification MeasurementCollectionJobFilesReadyEvent + * + * @param measurementCollectionJobFilesReadyEvent MeasurementCollectionJob filesReady Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "measurementCollectionJobFilesReadyEvent", + summary = "Client listener for entity MeasurementCollectionJobFilesReadyEvent", + description = "Example of a client listener for receiving the notification MeasurementCollectionJobFilesReadyEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/measurementCollectionJobFilesReadyEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> measurementCollectionJobFilesReadyEvent( + @Parameter(name = "MeasurementCollectionJobFilesReadyEvent", description = "MeasurementCollectionJob filesReady Event payload", required = true) @Valid @RequestBody MeasurementCollectionJobFilesReadyEvent measurementCollectionJobFilesReadyEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /listener/performanceMeasurementCollectionReadyEvent : Client listener for entity PerformanceMeasurementCollectionReadyEvent + * Example of a client listener for receiving the notification PerformanceMeasurementCollectionReadyEvent + * + * @param performanceMeasurementCollectionReadyEvent PerformanceMeasurement collectionReady Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "performanceMeasurementCollectionReadyEvent", + summary = "Client listener for entity PerformanceMeasurementCollectionReadyEvent", + description = "Example of a client listener for receiving the notification PerformanceMeasurementCollectionReadyEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/performanceMeasurementCollectionReadyEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> performanceMeasurementCollectionReadyEvent( + @Parameter(name = "PerformanceMeasurementCollectionReadyEvent", description = "PerformanceMeasurement collectionReady Event payload", required = true) @Valid @RequestBody PerformanceMeasurementCollectionReadyEvent performanceMeasurementCollectionReadyEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /listener/performanceMeasurementCreateEvent : Client listener for entity PerformanceMeasurementCreateEvent + * Example of a client listener for receiving the notification PerformanceMeasurementCreateEvent + * + * @param performanceMeasurementCreateEvent PerformanceMeasurement create Event payload (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "performanceMeasurementCreateEvent", + summary = "Client listener for entity PerformanceMeasurementCreateEvent", + description = "Example of a client listener for receiving the notification PerformanceMeasurementCreateEvent", + tags = { "notification listener" }, + responses = { + @ApiResponse(responseCode = "204", description = "Notified"), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/listener/performanceMeasurementCreateEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<Void> performanceMeasurementCreateEvent( + @Parameter(name = "PerformanceMeasurementCreateEvent", description = "PerformanceMeasurement create Event payload", required = true) @Valid @RequestBody PerformanceMeasurementCreateEvent performanceMeasurementCreateEvent + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..aab852d2b8a5ed0e91522911968fc0713e088092 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApiController.java @@ -0,0 +1,28 @@ +package org.etsi.osl.tmf.pm628.api; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller("ListenerApiController628") +@RequestMapping("/monitoring/v5") +public class ListenerApiController implements ListenerApi { + + private final NativeWebRequest request; + + @Autowired + public ListenerApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApi.java new file mode 100644 index 0000000000000000000000000000000000000000..e49e945b5590725be2958e8158def4abda998c76 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApi.java @@ -0,0 +1,692 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.common.model.Error; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobFVO; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobMVO; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "measurementCollectionJob", description = "Operations for MeasurementCollectionJob Resource") +public interface MeasurementCollectionJobApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * POST /measurementCollectionJob : Creates a MeasurementCollectionJob + * This operation creates a MeasurementCollectionJob entity. + * + * @param measurementCollectionJobFVO The MeasurementCollectionJob to be created (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return OK/Created (status code 201) + * or Accepted (status code 202) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "createMeasurementCollectionJob", + summary = "Creates a MeasurementCollectionJob", + description = "This operation creates a MeasurementCollectionJob entity.", + tags = { "measurementCollectionJob" }, + responses = { + @ApiResponse(responseCode = "201", description = "OK/Created", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MeasurementCollectionJob.class)) + }), + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/measurementCollectionJob", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<MeasurementCollectionJob> createMeasurementCollectionJob( + @Parameter(name = "MeasurementCollectionJobFVO", description = "The MeasurementCollectionJob to be created", required = true) @Valid @RequestBody MeasurementCollectionJobFVO measurementCollectionJobFVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"jobOnDemand\" : false, \"jobCollectionFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"searchTaskFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"outputFormat\" : \"outputFormat\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /measurementCollectionJob/{id} : Deletes a MeasurementCollectionJob + * This operation deletes a MeasurementCollectionJob entity. + * + * @param id Identifier of the Resource (required) + * @return Accepted (status code 202) + * or Deleted (status code 204) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "deleteMeasurementCollectionJob", + summary = "Deletes a MeasurementCollectionJob", + description = "This operation deletes a MeasurementCollectionJob entity.", + tags = { "measurementCollectionJob" }, + responses = { + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "204", description = "Deleted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/measurementCollectionJob/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<Void> deleteMeasurementCollectionJob( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /measurementCollectionJob : List or find MeasurementCollectionJob objects + * List or find MeasurementCollectionJob objects + * + * @param fields Comma-separated properties to be provided in response (optional) + * @param offset Requested index for start of resources to be provided in response (optional) + * @param limit Requested number of resources to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "listMeasurementCollectionJob", + summary = "List or find MeasurementCollectionJob objects", + description = "List or find MeasurementCollectionJob objects", + tags = { "measurementCollectionJob" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = MeasurementCollectionJob.class))) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/measurementCollectionJob", + produces = { "application/json" } + ) + + default ResponseEntity<List<MeasurementCollectionJob>> listMeasurementCollectionJob( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "allParams", description = "Filters to be applied in the query", in = ParameterIn.QUERY) @Valid @RequestParam(value = "allParams", required = false) Map<String, String> allParams, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "[ { \"jobOnDemand\" : false, \"jobCollectionFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"searchTaskFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"outputFormat\" : \"outputFormat\" }, { \"jobOnDemand\" : false, \"jobCollectionFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"searchTaskFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"outputFormat\" : \"outputFormat\" } ]"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PATCH /measurementCollectionJob/{id} : Updates partially a MeasurementCollectionJob + * This operation updates partially a MeasurementCollectionJob entity. + * + * @param id Identifier of the Resource (required) + * @param measurementCollectionJobMVO The MeasurementCollectionJob to be patched (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Accepted (status code 202) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "patchMeasurementCollectionJob", + summary = "Updates partially a MeasurementCollectionJob", + description = "This operation updates partially a MeasurementCollectionJob entity.", + tags = { "measurementCollectionJob" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MeasurementCollectionJob.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = MeasurementCollectionJob.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = MeasurementCollectionJob.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = MeasurementCollectionJob.class)) + }), + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/measurementCollectionJob/{id}", + produces = { "application/json", "application/merge-patch+json", "application/json-patch+json", "application/json-patch-query+json" }, + consumes = { "application/json", "application/merge-patch+json", "application/json-patch+json", "application/json-patch-query+json" } + ) + + default ResponseEntity<MeasurementCollectionJob> patchMeasurementCollectionJob( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "MeasurementCollectionJobMVO", description = "The MeasurementCollectionJob to be patched", required = true) @Valid @RequestBody MeasurementCollectionJobMVO measurementCollectionJobMVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"jobOnDemand\" : false, \"jobCollectionFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"searchTaskFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"outputFormat\" : \"outputFormat\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json-patch+json"))) { + String exampleString = "{ \"jobOnDemand\" : false, \"jobCollectionFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"searchTaskFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"outputFormat\" : \"outputFormat\" }"; + ApiUtil.setExampleResponse(request, "application/json-patch+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json-patch-query+json"))) { + String exampleString = "{ \"jobOnDemand\" : false, \"jobCollectionFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"searchTaskFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"outputFormat\" : \"outputFormat\" }"; + ApiUtil.setExampleResponse(request, "application/json-patch-query+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/merge-patch+json"))) { + String exampleString = "Custom MIME type example not yet supported: application/merge-patch+json"; + ApiUtil.setExampleResponse(request, "application/merge-patch+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /measurementCollectionJob/{id} : Retrieves a MeasurementCollectionJob by ID + * This operation retrieves a MeasurementCollectionJob entity. Attribute selection enabled for all first level attributes. + * + * @param id Identifier of the Resource (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "retrieveMeasurementCollectionJob", + summary = "Retrieves a MeasurementCollectionJob by ID", + description = "This operation retrieves a MeasurementCollectionJob entity. Attribute selection enabled for all first level attributes.", + tags = { "measurementCollectionJob" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MeasurementCollectionJob.class)) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/measurementCollectionJob/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<MeasurementCollectionJob> retrieveMeasurementCollectionJob( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"jobOnDemand\" : false, \"jobCollectionFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"searchTaskFilter\" : { \"mappings\" : [ { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } }, { \"filterTemplate\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"6c088cf7f1bc\", \"href\" : \"https://host/dataFilerTemplate/6c088cf7f1bc\", \"@schemaLocation\" : \"@schemaLocation\" }, \"stringArray\" : { \"valueType\" : \"valueType\", \"value\" : [ \"Dallas\", \"Houston\", \"Paris\" ] } } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"outputFormat\" : \"outputFormat\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..f23964e5bed8bf11da16c34ca98d5c6b4f0a3557 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiController.java @@ -0,0 +1,126 @@ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobFVO; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobMVO; +import org.etsi.osl.tmf.pm628.reposervices.MeasurementCollectionJobService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller +@RequestMapping("/monitoring/v5") +public class MeasurementCollectionJobApiController implements MeasurementCollectionJobApi { + + private static final Logger log = LoggerFactory.getLogger(MeasurementCollectionJobApiController.class); + + private final NativeWebRequest request; + + @Autowired + MeasurementCollectionJobService measurementCollectionJobService; + + @Autowired + public MeasurementCollectionJobApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<MeasurementCollectionJob> createMeasurementCollectionJob( + @Parameter(name = "MeasurementCollectionJobFVO", description = "The MeasurementCollectionJob to be created", required = true) @Valid @RequestBody MeasurementCollectionJobFVO measurementCollectionJobFVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + try { + return new ResponseEntity<MeasurementCollectionJob>(measurementCollectionJobService.createMeasurementCollectionJob(measurementCollectionJobFVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<MeasurementCollectionJob>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<Void> deleteMeasurementCollectionJob( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + try { + return new ResponseEntity<Void>(measurementCollectionJobService.deleteMeasurementCollectionJob(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<List<MeasurementCollectionJob>> listMeasurementCollectionJob( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "allParams", description = "Filters to be applied in the query", in = ParameterIn.QUERY) @Valid @RequestParam(value = "allParams", required = false) Map<String, String> allParams, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + try { + if (allParams == null) + allParams = new HashMap<>(); + + return new ResponseEntity<List<MeasurementCollectionJob>>(measurementCollectionJobService.findAll(fields, allParams), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<List<MeasurementCollectionJob>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<MeasurementCollectionJob> patchMeasurementCollectionJob( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "MeasurementCollectionJobMVO", description = "The MeasurementCollectionJob to be patched", required = true) @Valid @RequestBody MeasurementCollectionJobMVO measurementCollectionJobMVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + try { + return new ResponseEntity<MeasurementCollectionJob>(measurementCollectionJobService.updateMeasurementCollectionJob(id, measurementCollectionJobMVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<MeasurementCollectionJob>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<MeasurementCollectionJob> retrieveMeasurementCollectionJob( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + try { + return new ResponseEntity<MeasurementCollectionJob>(measurementCollectionJobService.findMeasurementCollectionJobByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<MeasurementCollectionJob>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..b8fbcca3e6274e3a625dcd4ba4440b3f5dc43959 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java @@ -0,0 +1,96 @@ +package org.etsi.osl.tmf.pm628.api; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.camel.LoggingLevel; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobFVO; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobMVO; +import org.etsi.osl.tmf.pm628.reposervices.MeasurementCollectionJobService; +import org.etsi.osl.tmf.pm628.api.MeasurementCollectionJobApiRouteBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +@Configuration +@Component +public class MeasurementCollectionJobApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(MeasurementCollectionJobApiRouteBuilder.class.getName()); + + @Value("${PM_MEASUREMENT_COLLECTION_JOBS_GET}") + private String PM_GET_MEASUREMENT_COLLECTION_JOBS; + + @Value("${PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID}") + private String PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID; + + @Value("${PM_MEASUREMENT_COLLECTION_JOB_ADD}") + private String PM_ADD_MEASUREMENT_COLLECTION_JOB; + + @Value("${PM_MEASUREMENT_COLLECTION_JOB_CREATED}") + private String PM_CREATED_MEASUREMENT_COLLECTION_JOB; + + @Value("${PM_MEASUREMENT_COLLECTION_JOB_UPDATE}") + private String PM_UPDATE_MEASUREMENT_COLLECTION_JOB; + + @Autowired + private ProducerTemplate template; + + @Autowired + MeasurementCollectionJobService measurementCollectionJobService; + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + from(PM_GET_MEASUREMENT_COLLECTION_JOBS) + .log(LoggingLevel.INFO, log, PM_GET_MEASUREMENT_COLLECTION_JOBS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean(measurementCollectionJobService, "findAllMeasurementCollectionJobs") + .convertBodyTo( String.class ); + + from(PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID) + .log(LoggingLevel.INFO, log, PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean(measurementCollectionJobService, "findMeasurementCollectionJobByUuidEagerAsString") + .convertBodyTo( String.class ); + + from(PM_ADD_MEASUREMENT_COLLECTION_JOB) + .log(LoggingLevel.INFO, log, PM_ADD_MEASUREMENT_COLLECTION_JOB + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal() + .json(JsonLibrary.Jackson, MeasurementCollectionJobFVO.class, true) + .bean(measurementCollectionJobService, "createMeasurementCollectionJob(${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from(PM_UPDATE_MEASUREMENT_COLLECTION_JOB) + .log(LoggingLevel.INFO, log, PM_UPDATE_MEASUREMENT_COLLECTION_JOB + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").unmarshal() + .json(JsonLibrary.Jackson, MeasurementCollectionJobMVO.class, true) + .bean(measurementCollectionJobService, "updateMeasurementCollectionJob(${header.mcjid}, ${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + } + + static String toJsonString(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString(object); + } + + static <T> T toJsonObj(String content, Class<T> valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.readValue( content, valueType); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilderEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..8bbb2fbd8bcea828db4e0083c5db9815870bcceb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilderEvents.java @@ -0,0 +1,103 @@ +package org.etsi.osl.tmf.pm628.api; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.pm628.model.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Configuration +//@RefreshScope +@Component +public class MeasurementCollectionJobApiRouteBuilderEvents extends RouteBuilder{ + + private static final transient Log logger = LogFactory.getLog(MeasurementCollectionJobApiRouteBuilderEvents.class.getName()); + + + @Value("${EVENT_MEASUREMENT_COLLECTION_JOB_CREATE}") + private String EVENT_MEASUREMENT_COLLECTION_JOB_CREATE=""; + + @Value("${EVENT_MEASUREMENT_COLLECTION_JOB_DELETE}") + private String EVENT_MEASUREMENT_COLLECTION_JOB_DELETE=""; + + @Value("${EVENT_MEASUREMENT_COLLECTION_JOB_ATTRIBUTE_VALUE_CHANGED}") + private String EVENT_MEASUREMENT_COLLECTION_JOB_ATTRIBUTE_VALUE_CHANGED=""; + + @Value("${EVENT_MEASUREMENT_COLLECTION_JOB_EXECUTION_STATE_CHANGED}") + private String EVENT_MEASUREMENT_COLLECTION_JOB_EXECUTION_STATE_CHANGED=""; + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private ProducerTemplate template; + + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + } + + @Transactional public void publishEvent(final Event event, final String objId) { + event.setEventType(event.getClass().getName()); + logger.info("will send Event for type " + event.getEventType()); + + try{ + String msgtopic = ""; + + if (event instanceof MeasurementCollectionJobCreateEvent) { + msgtopic = EVENT_MEASUREMENT_COLLECTION_JOB_CREATE; + } else if (event instanceof MeasurementCollectionJobDeleteEvent) { + msgtopic = EVENT_MEASUREMENT_COLLECTION_JOB_DELETE; + } else if (event instanceof MeasurementCollectionJobAttributeValueChangeEvent) { + msgtopic = EVENT_MEASUREMENT_COLLECTION_JOB_ATTRIBUTE_VALUE_CHANGED; + } else if (event instanceof MeasurementCollectionJobExecutionStateChangeEvent) { + msgtopic = EVENT_MEASUREMENT_COLLECTION_JOB_EXECUTION_STATE_CHANGED; + } + + Map<String, Object> map = new HashMap<>(); + map.put("eventid", event.getEventId() ); + map.put("objId", objId ); //measurementcollectionjob id + + String apayload = toJsonString(event); + template.sendBodyAndHeaders(msgtopic, apayload , map); + + centralLogger.log( CLevel.INFO, apayload, compname ); + } catch (Exception e) { + e.printStackTrace(); + logger.error("Cannot send Event . " + e.getMessage() ); + } + } + + + static String toJsonString(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString(object); + } + + static <T> T toJsonObj(String content, Class<T> valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.readValue( content, valueType); + } +} + + diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..e25a866c67752dbe03b4e46b7e393bb6f4e4b6cf --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApi.java @@ -0,0 +1,690 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.common.model.Error; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorGroupSpecification; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorGroupSpecificationFVO; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorGroupSpecificationMVO; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "performanceIndicatorGroupSpecification", description = "Operations for PerformanceIndicatorGroupSpecification Resource") +public interface PerformanceIndicatorGroupSpecificationApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * POST /performanceIndicatorGroupSpecification : Creates a PerformanceIndicatorGroupSpecification + * This operation creates a PerformanceIndicatorGroupSpecification entity. + * + * @param performanceIndicatorGroupSpecificationFVO The PerformanceIndicatorGroupSpecification to be created (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return OK/Created (status code 201) + * or Accepted (status code 202) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "createPerformanceIndicatorGroupSpecification", + summary = "Creates a PerformanceIndicatorGroupSpecification", + description = "This operation creates a PerformanceIndicatorGroupSpecification entity.", + tags = { "performanceIndicatorGroupSpecification" }, + responses = { + @ApiResponse(responseCode = "201", description = "OK/Created", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PerformanceIndicatorGroupSpecification.class)) + }), + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/performanceIndicatorGroupSpecification", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<PerformanceIndicatorGroupSpecification> createPerformanceIndicatorGroupSpecification( + @Parameter(name = "PerformanceIndicatorGroupSpecificationFVO", description = "The PerformanceIndicatorGroupSpecification to be created", required = true) @Valid @RequestBody PerformanceIndicatorGroupSpecificationFVO performanceIndicatorGroupSpecificationFVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"groupCategory\" : \"groupCategory\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"performanceIndicatorSpecification\" : [ { \"version\" : \"version\" }, { \"version\" : \"version\" } ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /performanceIndicatorGroupSpecification/{id} : Deletes a PerformanceIndicatorGroupSpecification + * This operation deletes a PerformanceIndicatorGroupSpecification entity. + * + * @param id Identifier of the Resource (required) + * @return Accepted (status code 202) + * or Deleted (status code 204) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "deletePerformanceIndicatorGroupSpecification", + summary = "Deletes a PerformanceIndicatorGroupSpecification", + description = "This operation deletes a PerformanceIndicatorGroupSpecification entity.", + tags = { "performanceIndicatorGroupSpecification" }, + responses = { + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "204", description = "Deleted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/performanceIndicatorGroupSpecification/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<Void> deletePerformanceIndicatorGroupSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /performanceIndicatorGroupSpecification : List or find PerformanceIndicatorGroupSpecification objects + * List or find PerformanceIndicatorGroupSpecification objects + * + * @param fields Comma-separated properties to be provided in response (optional) + * @param offset Requested index for start of resources to be provided in response (optional) + * @param limit Requested number of resources to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "listPerformanceIndicatorGroupSpecification", + summary = "List or find PerformanceIndicatorGroupSpecification objects", + description = "List or find PerformanceIndicatorGroupSpecification objects", + tags = { "performanceIndicatorGroupSpecification" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = PerformanceIndicatorGroupSpecification.class))) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/performanceIndicatorGroupSpecification", + produces = { "application/json" } + ) + + default ResponseEntity<List<PerformanceIndicatorGroupSpecification>> listPerformanceIndicatorGroupSpecification( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "[ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"groupCategory\" : \"groupCategory\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"performanceIndicatorSpecification\" : [ { \"version\" : \"version\" }, { \"version\" : \"version\" } ] }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"groupCategory\" : \"groupCategory\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"performanceIndicatorSpecification\" : [ { \"version\" : \"version\" }, { \"version\" : \"version\" } ] } ]"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PATCH /performanceIndicatorGroupSpecification/{id} : Updates partially a PerformanceIndicatorGroupSpecification + * This operation updates partially a PerformanceIndicatorGroupSpecification entity. + * + * @param id Identifier of the Resource (required) + * @param performanceIndicatorGroupSpecificationMVO The PerformanceIndicatorGroupSpecification to be patched (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Accepted (status code 202) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "patchPerformanceIndicatorGroupSpecification", + summary = "Updates partially a PerformanceIndicatorGroupSpecification", + description = "This operation updates partially a PerformanceIndicatorGroupSpecification entity.", + tags = { "performanceIndicatorGroupSpecification" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PerformanceIndicatorGroupSpecification.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = PerformanceIndicatorGroupSpecification.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = PerformanceIndicatorGroupSpecification.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = PerformanceIndicatorGroupSpecification.class)) + }), + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/performanceIndicatorGroupSpecification/{id}", + produces = { "application/json", "application/merge-patch+json", "application/json-patch+json", "application/json-patch-query+json" }, + consumes = { "application/json", "application/merge-patch+json", "application/json-patch+json", "application/json-patch-query+json" } + ) + + default ResponseEntity<PerformanceIndicatorGroupSpecification> patchPerformanceIndicatorGroupSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "PerformanceIndicatorGroupSpecificationMVO", description = "The PerformanceIndicatorGroupSpecification to be patched", required = true) @Valid @RequestBody PerformanceIndicatorGroupSpecificationMVO performanceIndicatorGroupSpecificationMVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"groupCategory\" : \"groupCategory\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"performanceIndicatorSpecification\" : [ { \"version\" : \"version\" }, { \"version\" : \"version\" } ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json-patch+json"))) { + String exampleString = "{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"groupCategory\" : \"groupCategory\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"performanceIndicatorSpecification\" : [ { \"version\" : \"version\" }, { \"version\" : \"version\" } ] }"; + ApiUtil.setExampleResponse(request, "application/json-patch+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json-patch-query+json"))) { + String exampleString = "{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"groupCategory\" : \"groupCategory\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"performanceIndicatorSpecification\" : [ { \"version\" : \"version\" }, { \"version\" : \"version\" } ] }"; + ApiUtil.setExampleResponse(request, "application/json-patch-query+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/merge-patch+json"))) { + String exampleString = "Custom MIME type example not yet supported: application/merge-patch+json"; + ApiUtil.setExampleResponse(request, "application/merge-patch+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /performanceIndicatorGroupSpecification/{id} : Retrieves a PerformanceIndicatorGroupSpecification by ID + * This operation retrieves a PerformanceIndicatorGroupSpecification entity. Attribute selection enabled for all first level attributes. + * + * @param id Identifier of the Resource (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "retrievePerformanceIndicatorGroupSpecification", + summary = "Retrieves a PerformanceIndicatorGroupSpecification by ID", + description = "This operation retrieves a PerformanceIndicatorGroupSpecification entity. Attribute selection enabled for all first level attributes.", + tags = { "performanceIndicatorGroupSpecification" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PerformanceIndicatorGroupSpecification.class)) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/performanceIndicatorGroupSpecification/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<PerformanceIndicatorGroupSpecification> retrievePerformanceIndicatorGroupSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"groupCategory\" : \"groupCategory\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"performanceIndicatorSpecification\" : [ { \"version\" : \"version\" }, { \"version\" : \"version\" } ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..03a4e52746ec4ea3fc1e460404975d0da98a3f0a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApiController.java @@ -0,0 +1,28 @@ +package org.etsi.osl.tmf.pm628.api; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller +@RequestMapping("/performance/v5") +public class PerformanceIndicatorGroupSpecificationApiController implements PerformanceIndicatorGroupSpecificationApi { + + private final NativeWebRequest request; + + @Autowired + public PerformanceIndicatorGroupSpecificationApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApi.java new file mode 100755 index 0000000000000000000000000000000000000000..f5c96ef885b2e767fc01120c1385a568ce0e6930 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApi.java @@ -0,0 +1,690 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.common.model.Error; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorSpecification; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorSpecificationFVO; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorSpecificationMVO; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "performanceIndicatorSpecification", description = "Operations for PerformanceIndicatorSpecification Resource") +public interface PerformanceIndicatorSpecificationApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * POST /performanceIndicatorSpecification : Creates a PerformanceIndicatorSpecification + * This operation creates a PerformanceIndicatorSpecification entity. + * + * @param performanceIndicatorSpecificationFVO The PerformanceIndicatorSpecification to be created (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return OK/Created (status code 201) + * or Accepted (status code 202) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "createPerformanceIndicatorSpecification", + summary = "Creates a PerformanceIndicatorSpecification", + description = "This operation creates a PerformanceIndicatorSpecification entity.", + tags = { "performanceIndicatorSpecification" }, + responses = { + @ApiResponse(responseCode = "201", description = "OK/Created", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PerformanceIndicatorSpecification.class)) + }), + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/performanceIndicatorSpecification", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity<PerformanceIndicatorSpecification> createPerformanceIndicatorSpecification( + @Parameter(name = "PerformanceIndicatorSpecificationFVO", description = "The PerformanceIndicatorSpecification to be created", required = true) @Valid @RequestBody PerformanceIndicatorSpecificationFVO performanceIndicatorSpecificationFVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"derivationAlgorithm\" : \"derivationAlgorithm\", \"derivationMethod\" : \"derivationMethod\", \"performanceIndicatorSpecRelationship\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } } ], \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"name\" : \"name\", \"description\" : \"description\", \"perspective\" : \"perspective\", \"indicatorCategory\" : \"indicatorCategory\", \"indicatorUnit\" : \"indicatorUnit\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /performanceIndicatorSpecification/{id} : Deletes a PerformanceIndicatorSpecification + * This operation deletes a PerformanceIndicatorSpecification entity. + * + * @param id Identifier of the Resource (required) + * @return Accepted (status code 202) + * or Deleted (status code 204) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "deletePerformanceIndicatorSpecification", + summary = "Deletes a PerformanceIndicatorSpecification", + description = "This operation deletes a PerformanceIndicatorSpecification entity.", + tags = { "performanceIndicatorSpecification" }, + responses = { + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "204", description = "Deleted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/performanceIndicatorSpecification/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<Void> deletePerformanceIndicatorSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /performanceIndicatorSpecification : List or find PerformanceIndicatorSpecification objects + * List or find PerformanceIndicatorSpecification objects + * + * @param fields Comma-separated properties to be provided in response (optional) + * @param offset Requested index for start of resources to be provided in response (optional) + * @param limit Requested number of resources to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "listPerformanceIndicatorSpecification", + summary = "List or find PerformanceIndicatorSpecification objects", + description = "List or find PerformanceIndicatorSpecification objects", + tags = { "performanceIndicatorSpecification" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = PerformanceIndicatorSpecification.class))) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/performanceIndicatorSpecification", + produces = { "application/json" } + ) + + default ResponseEntity<List<PerformanceIndicatorSpecification>> listPerformanceIndicatorSpecification( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "[ { \"derivationAlgorithm\" : \"derivationAlgorithm\", \"derivationMethod\" : \"derivationMethod\", \"performanceIndicatorSpecRelationship\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } } ], \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"name\" : \"name\", \"description\" : \"description\", \"perspective\" : \"perspective\", \"indicatorCategory\" : \"indicatorCategory\", \"indicatorUnit\" : \"indicatorUnit\" }, { \"derivationAlgorithm\" : \"derivationAlgorithm\", \"derivationMethod\" : \"derivationMethod\", \"performanceIndicatorSpecRelationship\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } } ], \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"name\" : \"name\", \"description\" : \"description\", \"perspective\" : \"perspective\", \"indicatorCategory\" : \"indicatorCategory\", \"indicatorUnit\" : \"indicatorUnit\" } ]"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PATCH /performanceIndicatorSpecification/{id} : Updates partially a PerformanceIndicatorSpecification + * This operation updates partially a PerformanceIndicatorSpecification entity. + * + * @param id Identifier of the Resource (required) + * @param performanceIndicatorSpecificationMVO The PerformanceIndicatorSpecification to be patched (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Accepted (status code 202) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Conflict (status code 409) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "patchPerformanceIndicatorSpecification", + summary = "Updates partially a PerformanceIndicatorSpecification", + description = "This operation updates partially a PerformanceIndicatorSpecification entity.", + tags = { "performanceIndicatorSpecification" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PerformanceIndicatorSpecification.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = PerformanceIndicatorSpecification.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = PerformanceIndicatorSpecification.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = PerformanceIndicatorSpecification.class)) + }), + @ApiResponse(responseCode = "202", description = "Accepted"), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "409", description = "Conflict", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/merge-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch+json", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json-patch-query+json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/performanceIndicatorSpecification/{id}", + produces = { "application/json", "application/merge-patch+json", "application/json-patch+json", "application/json-patch-query+json" }, + consumes = { "application/json", "application/merge-patch+json", "application/json-patch+json", "application/json-patch-query+json" } + ) + + default ResponseEntity<PerformanceIndicatorSpecification> patchPerformanceIndicatorSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "PerformanceIndicatorSpecificationMVO", description = "The PerformanceIndicatorSpecification to be patched", required = true) @Valid @RequestBody PerformanceIndicatorSpecificationMVO performanceIndicatorSpecificationMVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"derivationAlgorithm\" : \"derivationAlgorithm\", \"derivationMethod\" : \"derivationMethod\", \"performanceIndicatorSpecRelationship\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } } ], \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"name\" : \"name\", \"description\" : \"description\", \"perspective\" : \"perspective\", \"indicatorCategory\" : \"indicatorCategory\", \"indicatorUnit\" : \"indicatorUnit\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json-patch+json"))) { + String exampleString = "{ \"derivationAlgorithm\" : \"derivationAlgorithm\", \"derivationMethod\" : \"derivationMethod\", \"performanceIndicatorSpecRelationship\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } } ], \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"name\" : \"name\", \"description\" : \"description\", \"perspective\" : \"perspective\", \"indicatorCategory\" : \"indicatorCategory\", \"indicatorUnit\" : \"indicatorUnit\" }"; + ApiUtil.setExampleResponse(request, "application/json-patch+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json-patch-query+json"))) { + String exampleString = "{ \"derivationAlgorithm\" : \"derivationAlgorithm\", \"derivationMethod\" : \"derivationMethod\", \"performanceIndicatorSpecRelationship\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } } ], \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"name\" : \"name\", \"description\" : \"description\", \"perspective\" : \"perspective\", \"indicatorCategory\" : \"indicatorCategory\", \"indicatorUnit\" : \"indicatorUnit\" }"; + ApiUtil.setExampleResponse(request, "application/json-patch-query+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/merge-patch+json"))) { + String exampleString = "Custom MIME type example not yet supported: application/merge-patch+json"; + ApiUtil.setExampleResponse(request, "application/merge-patch+json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /performanceIndicatorSpecification/{id} : Retrieves a PerformanceIndicatorSpecification by ID + * This operation retrieves a PerformanceIndicatorSpecification entity. Attribute selection enabled for all first level attributes. + * + * @param id Identifier of the Resource (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "retrievePerformanceIndicatorSpecification", + summary = "Retrieves a PerformanceIndicatorSpecification by ID", + description = "This operation retrieves a PerformanceIndicatorSpecification entity. Attribute selection enabled for all first level attributes.", + tags = { "performanceIndicatorSpecification" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PerformanceIndicatorSpecification.class)) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/performanceIndicatorSpecification/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<PerformanceIndicatorSpecification> retrievePerformanceIndicatorSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"derivationAlgorithm\" : \"derivationAlgorithm\", \"derivationMethod\" : \"derivationMethod\", \"performanceIndicatorSpecRelationship\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" } } ], \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"name\" : \"name\", \"description\" : \"description\", \"perspective\" : \"perspective\", \"indicatorCategory\" : \"indicatorCategory\", \"indicatorUnit\" : \"indicatorUnit\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApiController.java new file mode 100755 index 0000000000000000000000000000000000000000..d86b31fdbf108dab0889a1f92f291e8d91bf68e4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApiController.java @@ -0,0 +1,123 @@ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorSpecification; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorSpecificationFVO; +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorSpecificationMVO; +import org.etsi.osl.tmf.pm628.reposervices.PerformanceIndicatorSpecificationService; +import org.etsi.osl.tmf.pm628.api.PerformanceIndicatorSpecificationApiController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller +@RequestMapping("/performance/v5") +public class PerformanceIndicatorSpecificationApiController implements PerformanceIndicatorSpecificationApi { + + private static final Logger log = LoggerFactory.getLogger(PerformanceIndicatorSpecificationApiController.class); + + private final NativeWebRequest request; + + @Autowired + PerformanceIndicatorSpecificationService performanceIndicatorSpecificationService; + + @Autowired + public PerformanceIndicatorSpecificationApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<PerformanceIndicatorSpecification> createPerformanceIndicatorSpecification( + @Parameter(name = "PerformanceIndicatorSpecificationFVO", description = "The PerformanceIndicatorSpecification to be created", required = true) @Valid @RequestBody PerformanceIndicatorSpecificationFVO performanceIndicatorSpecificationFVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + try { + return new ResponseEntity<PerformanceIndicatorSpecification>(performanceIndicatorSpecificationService.createPerformanceIndicatorSpecification(performanceIndicatorSpecificationFVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<PerformanceIndicatorSpecification>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<Void> deletePerformanceIndicatorSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + try { + return new ResponseEntity<Void>(performanceIndicatorSpecificationService.deletePerformanceIndicatorSpecification(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<List<PerformanceIndicatorSpecification>> listPerformanceIndicatorSpecification( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + try { + // #TODO: Add parameters to findAllPerformanceIndicatorSpecifications + return new ResponseEntity<List<PerformanceIndicatorSpecification>>(performanceIndicatorSpecificationService.findAllPerformanceIndicatorSpecifications(), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<List<PerformanceIndicatorSpecification>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<PerformanceIndicatorSpecification> patchPerformanceIndicatorSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "PerformanceIndicatorSpecificationMVO", description = "The PerformanceIndicatorSpecification to be patched", required = true) @Valid @RequestBody PerformanceIndicatorSpecificationMVO performanceIndicatorSpecificationMVO, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + try { + return new ResponseEntity<PerformanceIndicatorSpecification>(performanceIndicatorSpecificationService.updatePerformanceIndicatorSpecification(id, performanceIndicatorSpecificationMVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<PerformanceIndicatorSpecification>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity<PerformanceIndicatorSpecification> retrievePerformanceIndicatorSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + try { + // #TODO: Add parameters to findPerformanceIndicatorSpecificationByUuid + return new ResponseEntity<PerformanceIndicatorSpecification>(performanceIndicatorSpecificationService.findPerformanceIndicatorSpecificationByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<PerformanceIndicatorSpecification>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApi.java new file mode 100644 index 0000000000000000000000000000000000000000..cc3a71f6ba89dc68cde788a7e4a8321f083d69c3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApi.java @@ -0,0 +1,273 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.common.model.Error; +import org.etsi.osl.tmf.pm628.model.PerformanceMeasurement; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "performanceMeasurement", description = "Operations for PerformanceMeasurement Resource") +public interface PerformanceMeasurementApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * GET /performanceMeasurement : List or find PerformanceMeasurement objects + * List or find PerformanceMeasurement objects + * + * @param fields Comma-separated properties to be provided in response (optional) + * @param offset Requested index for start of resources to be provided in response (optional) + * @param limit Requested number of resources to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "listPerformanceMeasurement", + summary = "List or find PerformanceMeasurement objects", + description = "List or find PerformanceMeasurement objects", + tags = { "performanceMeasurement" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = PerformanceMeasurement.class))) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/performanceMeasurement", + produces = { "application/json" } + ) + + default ResponseEntity<List<PerformanceMeasurement>> listPerformanceMeasurement( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "[ { \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"measurementCollectionJob\" : { }, \"description\" : \"description\", \"relatedMeasurement\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"relatedMeasurement\" : { \"version\" : \"version\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"relatedMeasurement\" : { \"version\" : \"version\" } } ] }, { \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"measurementCollectionJob\" : { }, \"description\" : \"description\", \"relatedMeasurement\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"relatedMeasurement\" : { \"version\" : \"version\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"relatedMeasurement\" : { \"version\" : \"version\" } } ] } ]"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /performanceMeasurement/{id} : Retrieves a PerformanceMeasurement by ID + * This operation retrieves a PerformanceMeasurement entity. Attribute selection enabled for all first level attributes. + * + * @param id Identifier of the Resource (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "retrievePerformanceMeasurement", + summary = "Retrieves a PerformanceMeasurement by ID", + description = "This operation retrieves a PerformanceMeasurement entity. Attribute selection enabled for all first level attributes.", + tags = { "performanceMeasurement" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PerformanceMeasurement.class)) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/performanceMeasurement/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<PerformanceMeasurement> retrievePerformanceMeasurement( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"measurementCollectionJob\" : { }, \"description\" : \"description\", \"relatedMeasurement\" : [ { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"relatedMeasurement\" : { \"version\" : \"version\" } }, { \"role\" : \"role\", \"relationshipType\" : \"relationshipType\", \"validFor\" : { \"startDateTime\" : \"1985-04-12T23:20:50.52Z\", \"endDateTime\" : \"1985-04-12T23:20:50.52Z\" }, \"relatedMeasurement\" : { \"version\" : \"version\" } } ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..d9e059e8e3e5f5488beeed60e95a810a098bed73 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApiController.java @@ -0,0 +1,28 @@ +package org.etsi.osl.tmf.pm628.api; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller +@RequestMapping("/performance/v5") +public class PerformanceMeasurementApiController implements PerformanceMeasurementApi { + + private final NativeWebRequest request; + + @Autowired + public PerformanceMeasurementApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApi.java b/src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApi.java new file mode 100644 index 0000000000000000000000000000000000000000..516e9741de4f19c5395c3c7c48dc2b41bfd0454c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApi.java @@ -0,0 +1,273 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm628.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.common.model.Error; +import org.etsi.osl.tmf.pm628.model.TrackingRecord; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.List; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Validated +@Tag(name = "trackingRecord", description = "Operations for TrackingRecord Resource") +public interface TrackingRecordApi { + + default Optional<NativeWebRequest> getRequest() { + return Optional.empty(); + } + + /** + * GET /trackingRecord : List or find TrackingRecord objects + * List or find TrackingRecord objects + * + * @param fields Comma-separated properties to be provided in response (optional) + * @param offset Requested index for start of resources to be provided in response (optional) + * @param limit Requested number of resources to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "listTrackingRecord", + summary = "List or find TrackingRecord objects", + description = "List or find TrackingRecord objects", + tags = { "trackingRecord" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = TrackingRecord.class))) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/trackingRecord", + produces = { "application/json" } + ) + + default ResponseEntity<List<TrackingRecord>> listTrackingRecord( + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "[ { \"systemId\" : \"systemId\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"description\" : \"[\\\"acknowledge\\\",\\\"clear\\\"]\", \"time\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"user\" : \"user\", \"characteristic\" : [ { \"characteristicRelationship\" : [ { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"characteristicRelationship\" : [ { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ] }, { \"systemId\" : \"systemId\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"description\" : \"[\\\"acknowledge\\\",\\\"clear\\\"]\", \"time\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"user\" : \"user\", \"characteristic\" : [ { \"characteristicRelationship\" : [ { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"characteristicRelationship\" : [ { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ] } ]"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /trackingRecord/{id} : Retrieves a TrackingRecord by ID + * This operation retrieves a TrackingRecord entity. Attribute selection enabled for all first level attributes. + * + * @param id Identifier of the Resource (required) + * @param fields Comma-separated properties to be provided in response (optional) + * @return Success (status code 200) + * or Bad Request (status code 400) + * or Unauthorized (status code 401) + * or Forbidden (status code 403) + * or Not Found (status code 404) + * or Method Not allowed (status code 405) + * or Internal Server Error (status code 500) + * or Not Implemented (status code 501) + * or Service Unavailable (status code 503) + */ + @Operation( + operationId = "retrieveTrackingRecord", + summary = "Retrieves a TrackingRecord by ID", + description = "This operation retrieves a TrackingRecord entity. Attribute selection enabled for all first level attributes.", + tags = { "trackingRecord" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = TrackingRecord.class)) + }), + @ApiResponse(responseCode = "400", description = "Bad Request", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "403", description = "Forbidden", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "404", description = "Not Found", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "405", description = "Method Not allowed", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "501", description = "Not Implemented", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }), + @ApiResponse(responseCode = "503", description = "Service Unavailable", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/trackingRecord/{id}", + produces = { "application/json" } + ) + + default ResponseEntity<TrackingRecord> retrieveTrackingRecord( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id, + @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"systemId\" : \"systemId\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"description\" : \"[\\\"acknowledge\\\",\\\"clear\\\"]\", \"time\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"user\" : \"user\", \"characteristic\" : [ { \"characteristicRelationship\" : [ { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"characteristicRelationship\" : [ { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"@baseType\" : \"@baseType\", \"relationshipType\" : \"relationshipType\", \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\" } ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApiController.java b/src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..0cddb3105831ecc54c396e30fe1ddded18de1132 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApiController.java @@ -0,0 +1,28 @@ +package org.etsi.osl.tmf.pm628.api; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; + +import javax.annotation.Generated; +import java.util.Optional; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller +@RequestMapping("/performance/v5") +public class TrackingRecordApiController implements TrackingRecordApi { + + private final NativeWebRequest request; + + @Autowired + public TrackingRecordApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional<NativeWebRequest> getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/repo/DataAccessEndpointRepository.java b/src/main/java/org/etsi/osl/tmf/pm628/repo/DataAccessEndpointRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..71ae6bc132c975cac4e54b9a999b06dbbbc4454d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/repo/DataAccessEndpointRepository.java @@ -0,0 +1,13 @@ +package org.etsi.osl.tmf.pm628.repo; + +import org.etsi.osl.tmf.pm628.model.DataAccessEndpoint; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface DataAccessEndpointRepository extends CrudRepository<DataAccessEndpoint, Long>, PagingAndSortingRepository<DataAccessEndpoint, Long> { + Optional<DataAccessEndpoint> findByUuid(String uuid); +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/repo/MeasurementCollectionJobRepository.java b/src/main/java/org/etsi/osl/tmf/pm628/repo/MeasurementCollectionJobRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..244016e6ac5e3a54a9ffb81ea4715469b7877013 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/repo/MeasurementCollectionJobRepository.java @@ -0,0 +1,14 @@ +package org.etsi.osl.tmf.pm628.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.pm628.model.ExecutionStateType; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MeasurementCollectionJobRepository extends JpaRepository <MeasurementCollectionJob, Long> { + Optional<MeasurementCollectionJob> findByUuid(String uuid); + + Iterable<MeasurementCollectionJob> findByExecutionState(ExecutionStateType executionState); +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/repo/PerformanceIndicatorSpecificationRepository.java b/src/main/java/org/etsi/osl/tmf/pm628/repo/PerformanceIndicatorSpecificationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..0764d9cf5eb21521e26c7f6fe7ddfedf0eac9a16 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/repo/PerformanceIndicatorSpecificationRepository.java @@ -0,0 +1,13 @@ +package org.etsi.osl.tmf.pm628.repo; + +import org.etsi.osl.tmf.pm628.model.PerformanceIndicatorSpecification; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface PerformanceIndicatorSpecificationRepository extends CrudRepository<PerformanceIndicatorSpecification, Long>, PagingAndSortingRepository<PerformanceIndicatorSpecification, Long> { + Optional<PerformanceIndicatorSpecification> findByUuid(String uuid); +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/reposervices/DataAccessEndpointService.java b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/DataAccessEndpointService.java new file mode 100644 index 0000000000000000000000000000000000000000..4b7c0029973246454c257e99a4c22c9738151da7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/DataAccessEndpointService.java @@ -0,0 +1,71 @@ +package org.etsi.osl.tmf.pm628.reposervices; + + +import jakarta.validation.Valid; +import org.etsi.osl.tmf.pm628.model.DataAccessEndpoint; +import org.etsi.osl.tmf.pm628.model.DataAccessEndpointFVO; +import org.etsi.osl.tmf.pm628.model.DataAccessEndpointMVO; +import org.etsi.osl.tmf.pm628.model.DataAccessEndpointMapper; +import org.etsi.osl.tmf.pm628.repo.DataAccessEndpointRepository; +import org.mapstruct.factory.Mappers; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +@Service +@Transactional +public class DataAccessEndpointService { + + private static final Logger log = LoggerFactory.getLogger(DataAccessEndpointService.class); + + private final DataAccessEndpointRepository dataAccessEndpointRepository; + + @Autowired + public DataAccessEndpointService(DataAccessEndpointRepository dataAccessEndpointRepository) { + this.dataAccessEndpointRepository = dataAccessEndpointRepository; + } + + public List<DataAccessEndpoint> findAllDataAccessEndpoints(){ + log.debug("DataAccessEndpoint LIST"); + return (List<DataAccessEndpoint>) dataAccessEndpointRepository.findAll(); + } + + public DataAccessEndpoint findDataAccessEndpointByUuid(String uuid){ + log.debug("DataAccessEndpoint FIND BY UUID"); + Optional<DataAccessEndpoint> dataAccessEndpoint = dataAccessEndpointRepository.findByUuid(uuid); + return dataAccessEndpoint.orElse(null); + } + + public DataAccessEndpoint createDataAccessEndpoint(DataAccessEndpointFVO dataAccessEndpointFVO){ + log.debug("DataAccessEndpoint CREATE: {}",dataAccessEndpointFVO); + + DataAccessEndpointMapper mapper = Mappers.getMapper(DataAccessEndpointMapper.class); + DataAccessEndpoint dataAccessEndpoint = mapper.createDataAccessEndpoint(dataAccessEndpointFVO); + + return dataAccessEndpointRepository.save(dataAccessEndpoint); + } + + public DataAccessEndpoint updateDataAccessEndpoint(String uuid, @Valid DataAccessEndpointMVO dataAccessEndpointUpdate){ + log.debug("DataAccessEndpoint UPDATE with UUID: {}", uuid); + DataAccessEndpoint dataAccessEndpoint = dataAccessEndpointRepository.findByUuid(uuid). + orElseThrow(() -> new IllegalArgumentException("No Data Access Endpoint with UUID: " + uuid)); + + DataAccessEndpointMapper mapper = Mappers.getMapper(DataAccessEndpointMapper.class); + + dataAccessEndpoint = mapper.updateDataAccessEndpoint(dataAccessEndpointUpdate, dataAccessEndpoint); + dataAccessEndpointRepository.save(dataAccessEndpoint); + return dataAccessEndpoint; + } + + public void deleteDataAccessEndpoint(String uuid){ + log.debug("DataAccessEndpoint DELETE with UUID:{}", uuid); + DataAccessEndpoint dataAccessEndpoint = dataAccessEndpointRepository.findByUuid(uuid) + .orElseThrow(() -> new IllegalArgumentException("No Data Access Endpoint with UUID: " + uuid)); + dataAccessEndpointRepository.delete(dataAccessEndpoint); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java new file mode 100755 index 0000000000000000000000000000000000000000..4ca0ceaeb4875242189cd57f36867ee9984a4d92 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java @@ -0,0 +1,459 @@ +package org.etsi.osl.tmf.pm628.reposervices; + +import jakarta.persistence.EntityManagerFactory; +import org.hibernate.query.Query; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.pm628.api.MeasurementCollectionJobApiRouteBuilderEvents; +import org.etsi.osl.tmf.pm628.model.*; +import org.etsi.osl.tmf.pm628.repo.MeasurementCollectionJobRepository; +import org.etsi.osl.tmf.so641.model.ServiceOrder; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.mapstruct.factory.Mappers; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.*; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; + +@Service +@Transactional +public class MeasurementCollectionJobService { + + private static final Logger log = LoggerFactory.getLogger(MeasurementCollectionJobService.class); + + @Autowired + private final MeasurementCollectionJobRepository measurementCollectionJobRepository; + + @Autowired + MeasurementCollectionJobApiRouteBuilderEvents routeBuilderEvents; + + private SessionFactory sessionFactory; + + @Autowired + public MeasurementCollectionJobService(MeasurementCollectionJobRepository measurementCollectionJobRepository, EntityManagerFactory factory) { + this.measurementCollectionJobRepository = measurementCollectionJobRepository; + + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public List<MeasurementCollectionJob> findAllMeasurementCollectionJobs(){ + log.debug("MeasurementCollectionJobService: LIST"); + return (List<MeasurementCollectionJob>) measurementCollectionJobRepository.findAll(); + } + + public List<MeasurementCollectionJob> findAllByExecutionState(ExecutionStateType executionState) { + log.debug("find by state:" + executionState ); + return (List<MeasurementCollectionJob>) this.measurementCollectionJobRepository.findByExecutionState(executionState); + } + + @Transactional + public List findAll(@Valid String fields, Map<String, String> allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List<Map<String, Object>> resultList = new ArrayList<>(); + + try { + StringBuilder sql = new StringBuilder("SELECT "); + sql.append("mcj.uuid as uuid, ") + .append("mcj.creationTime as creationTime, ") + .append("mcj.reportingPeriod as reportingPeriod, ") + .append("mcj.granularity as granularity, ") + .append("mcj.consumingApplicationId as consumingApplicationId, ") + .append("mcj.producingApplicationId as producingApplicationId, ") + .append("mcj.executionState as executionState, ") + .append("mcj.jobId as jobId, ") + // DataAccessEndpoint attributes + .append("dae.uuid as dataAccessEndpoint_uuid, ") + .append("dae.uri as dataAccessEndpoint_uri, ") + .append("dae.apiType as dataAccessEndpoint_apiType, ") + .append("dae.resourceStatus as dataAccessEndpoint_resourceStatus, ") + .append("dae.operationalState as dataAccessEndpoint_operationalState, ") + // DataAccessEndpoint uriQueryFilter mappings attributes + .append("map.filterTemplate.name as dae_uriqf_mapping_name, ") + .append("map.filterTemplate.description as dae_uriqf_mapping_description, ") + .append("map.stringArray.value as dae_uriqf_mapping_value, ") + .append("map.filterTemplate.id as dae_uriqf_mapping_id, ") + // DataAccessEndpoint resourceOrderItem attributes + .append("roi.resourceOrderHref as dae_resOrdItem_resourceOrderHref, ") + .append("roi.resourceOrderId as dae_resOrdItem_resourceOrderId, ") + .append("roi.itemAction as dae_resOrdItem_itemAction, ") + .append("roi.itemId as dae_resOrdItem_itemId, ") + .append("roi.role as dae_resOrdItem_role, ") + // ScheduleDefinition attributes + .append("sd.scheduleDefinitionStartTime as scheduleDefinition_startTime, ") + .append("sd.scheduleDefinitionEndTime as scheduleDefinition_endTime, ") + .append("sd.recurringFrequency as scheduleDefinition_recurringFrequency, ") + .append("sd.excludedDate as scheduleDefinition_excludedDate, ") + .append("sd.scheduleDefinitionHourRange as scheduleDefinition_hourRange, ") + .append("sd.monthlyScheduleDayOfMonthDefinition as scheduleDefinition_monthlyScheduleDayOfMonthDefinition, ") + .append("sd.dateScheduleDefintion as scheduleDefinition_dateScheduleDefintion, ") + .append("wsd.dates as scheduleDefinition_weeklyScheduledDefinition_Dates, ") + .append("sd.monthlyScheduleDayOfWeekDefinition.recurringDaySequence as scheduleDefinition_monthlyScheduleDayOfWeekDefinition_recurringDaySequence, ") + .append("domr.dates as scheduleDefinition_monthlyScheduleDayOfWeekDefinition_dayOfMonthRecurrence_dates "); + + if (fields != null && !fields.isEmpty()) { + String[] fieldArray = fields.split(","); + for (String field : fieldArray) { + sql.append(", mcj.").append(field.trim()).append(" as ").append(field.trim()); + } + } + + sql.append(" FROM PM628_MCJob mcj ") + .append("LEFT JOIN mcj.dataAccessEndpoint dae ") + .append("LEFT JOIN dae.uriQueryFilter.mappings map ") + .append("LEFT JOIN dae.resourceOrderItem roi ") + .append("LEFT JOIN mcj.scheduleDefinition sd ") + .append("LEFT JOIN sd.weeklyScheduledDefinition wsd ") + .append("LEFT JOIN sd.monthlyScheduleDayOfWeekDefinition.dayOfMonthRecurrence domr "); + + if (!allParams.isEmpty()) { + sql.append(" WHERE "); + for (String paramName : allParams.keySet()) { + sql.append("mcj.").append(paramName).append(" LIKE :").append(paramName).append(" AND "); + } + sql.setLength(sql.length() - 5); // Remove the last " AND " + } + + sql.append(" ORDER BY mcj.creationTime DESC"); + + Query query = session.createQuery(sql.toString()); + for (Map.Entry<String, String> entry : allParams.entrySet()) { + query.setParameter(entry.getKey(), "%" + URLDecoder.decode(entry.getValue(), StandardCharsets.UTF_8.toString()) + "%"); + } + + List<Object[]> queryResult = query.list(); + Map<String, Map<String, Object>> mcJobMap = new LinkedHashMap<>(); + Map<String, Map<String, Object>> daeMap = new LinkedHashMap<>(); + Map<String, Map<String, Object>> sdMap = new LinkedHashMap<>(); + + for (Object[] row : queryResult) { + String mcjUuid = (String) row[0]; + + // If this mcjUuid hasn't been seen, create a new entry for it + mcJobMap.computeIfAbsent(mcjUuid, k -> { + Map<String, Object> mcJobData = new LinkedHashMap<>(); + mcJobData.put("uuid", row[0]); + mcJobData.put("creationTime", row[1]); + mcJobData.put("reportingPeriod", row[2]); + mcJobData.put("granularity", row[3]); + mcJobData.put("consumingApplicationId", row[4]); + mcJobData.put("producingApplicationId", row[5]); + mcJobData.put("executionState", row[6]); + mcJobData.put("jobId", row[7]); + mcJobData.put("dataAccessEndpoint", new ArrayList<Map<String, Object>>()); + mcJobData.put("scheduleDefinition", new ArrayList<Map<String, Object>>()); + + if (fields != null && !fields.isEmpty()) { + String[] fieldArray = fields.split(","); + for (int i = 0; i < fieldArray.length; i++) { + mcJobData.put(fieldArray[i].trim(), row[9 + i]); + } + } + return mcJobData; + }); + + String daeUuid = (String) row[8]; + + // Check if DataAccessEndpoint fields are null; if so, skip adding it + if (daeUuid != null) { + Map<String, Object> daeData = daeMap.computeIfAbsent(daeUuid, k -> { + Map<String, Object> newDaeData = new LinkedHashMap<>(); + newDaeData.put("uuid", row[8]); + newDaeData.put("uri", row[9]); + newDaeData.put("apiType", row[10]); + newDaeData.put("resourceStatus", row[11]); + newDaeData.put("operationalState", row[12]); + newDaeData.put("uriQueryFilter", new LinkedHashMap<String, Object>()); + newDaeData.put("resourceOrderItem", new ArrayList<Map<String, Object>>()); + ((List<Map<String, Object>>) mcJobMap.get(mcjUuid).get("dataAccessEndpoint")).add(newDaeData); + return newDaeData; + }); + + // Create uriQueryFilter map and add mappings + Map<String, Object> uriQueryFilter = (Map<String, Object>) daeData.get("uriQueryFilter"); + Set<Map<String, Object>> mappingsSet = (Set<Map<String, Object>>) uriQueryFilter.computeIfAbsent("mappings", k -> new LinkedHashSet<>()); + + // Check if mapping fields are null; if so, skip adding it + if (row[13] != null || row[14] != null || row[15] != null || row[16] != null) { + Map<String, Object> mappingData = new LinkedHashMap<>(); + mappingData.put("name", row[13]); + mappingData.put("description", row[14]); + mappingData.put("value", row[15]); + mappingData.put("id", row[16]); + mappingsSet.add(mappingData); + } + + // Retrieve resourceOrderItem and add to DAE + List<Map<String, Object>> roiList = (List<Map<String, Object>>) daeData.get("resourceOrderItem"); + + // Check if resource order item fields are null; if so, skip adding it + if (row[17] != null || row[18] != null || row[19] != null || row[20] != null || row[21] != null) { + Map<String, Object> roiData = new LinkedHashMap<>(); + roiData.put("resourceOrderHref", row[17]); + roiData.put("resourceOrderId", row[18]); + roiData.put("itemAction", row[19]); + roiData.put("itemId", row[20]); + roiData.put("role", row[21]); + roiList.add(roiData); + } + } + + // Check if ScheduleDefinition fields are null; if so, skip adding it + if (row[22] != null || row[23] != null || row[24] != null || row[25] != null || row[26] != null || row[27] != null || row[28] != null || row[29] != null | row[30] != null) { + String sdUuid = mcjUuid + "_" + row[22] + "_" + row[23]; // Unique key for schedule definition + + Map<String, Object> sdData = sdMap.computeIfAbsent(sdUuid, k -> { + Map<String, Object> newSdData = new LinkedHashMap<>(); + newSdData.put("scheduleDefinitionStartTime", row[22]); + newSdData.put("scheduleDefinitionEndTime", row[23]); + newSdData.put("recurringFrequency", row[24]); + newSdData.put("excludedDate", new LinkedHashSet<>()); + newSdData.put("scheduleDefinitionHourRange", row[26]); + newSdData.put("monthlyScheduleDayOfMonthDefinition", new LinkedHashSet<>()); + newSdData.put("dateScheduleDefintion", new LinkedHashSet<>()); + newSdData.put("weeklyScheduledDefinition", new LinkedHashMap<>()); + newSdData.put("monthlyScheduleDayOfWeekDefinition", new LinkedHashMap<>()); + ((List<Map<String, Object>>) mcJobMap.get(mcjUuid).get("scheduleDefinition")).add(newSdData); + return newSdData; + }); + + // Add excludedDate + if (row[25] != null) { + ((Set<Object>) sdData.get("excludedDate")).add(row[25]); + } + + // Add monthlyScheduleDayOfMonthDefinition + if (row[27] != null) { + ((Set<Object>) sdData.get("monthlyScheduleDayOfMonthDefinition")).add(row[27]); + } + + // Add dateScheduleDefintion + if (row[28] != null) { + ((Set<Object>) sdData.get("dateScheduleDefintion")).add(row[28]); + } + + // Add weeklyScheduledDefinition + Map<String, Object> weeklyScheduledDefinition = (Map<String, Object>) sdData.get("weeklyScheduledDefinition"); + if (row[29] != null) { + Set<Map<String, Object>> dayOfWeekRecurrence = (Set<Map<String, Object>>) weeklyScheduledDefinition.computeIfAbsent("dayOfWeekRecurrence", k -> new LinkedHashSet<>()); + Map<String, Object> wsdData = new LinkedHashMap<>(); + wsdData.put("dates", row[29]); + dayOfWeekRecurrence.add(wsdData); + } + + // Add monthlyScheduleDayOfWeekDefinition + Map<String, Object> monthlyScheduleDayOfWeekDefinition = (Map<String, Object>) sdData.get("monthlyScheduleDayOfWeekDefinition"); + if (row[30] != null) { + monthlyScheduleDayOfWeekDefinition.put("recurringDaySequence", row[30]); + } + if (row[31] != null) { + Set<Map<String, Object>> dayOfMonthRecurrence = (Set<Map<String, Object>>) monthlyScheduleDayOfWeekDefinition.computeIfAbsent("dayOfMonthRecurrence", k -> new LinkedHashSet<>()); + Map<String, Object> domrData = new LinkedHashMap<>(); + domrData.put("dates", row[31]); + dayOfMonthRecurrence.add(domrData); + } + } + } + resultList.addAll(mcJobMap.values()); + } catch (Exception e) { + if (tx != null) { + tx.rollback(); + } + log.error("Error executing query", e); + } finally { + tx.commit(); + session.close(); + } + + return resultList; + } + + @Transactional + public String findMeasurementCollectionJobByUuidEagerAsString(String uuid) throws JsonProcessingException{ + + MeasurementCollectionJob mcj = findMeasurementCollectionJobByUuidEager(uuid); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString(mcj); + log.debug("=====> MCJObjectMapper {}", res); + return res; + + } + + + @Transactional + private MeasurementCollectionJob findMeasurementCollectionJobByUuidEager(String id) { + if (id == null || id.equals("")) { + return null; + } + MeasurementCollectionJob s = null; + try (Session session = sessionFactory.openSession()) { + Transaction tx = session.beginTransaction(); + s = (MeasurementCollectionJob) session.get(MeasurementCollectionJob.class, id); + if (s == null) { + log.debug("=====> findMeasurementCollectionJobByUuidEager last resort"); + return this.findMeasurementCollectionJobByUuid(id);// last resort + } + + Hibernate.initialize(s.getDataAccessEndpoint()); + Hibernate.initialize(s.getFileTransferData()); + Hibernate.initialize(s.getPerformanceIndicatorGroupSpecification()); + Hibernate.initialize(s.getPerformanceIndicatorSpecification()); + Hibernate.initialize(s.getScheduleDefinition()); + Hibernate.initialize(s.getTrackingRecord()); + + tx.commit(); + } catch (Exception e) { + e.printStackTrace(); + } + + return s; + } + + @Transactional + public MeasurementCollectionJob findMeasurementCollectionJobByUuid(String uuid){ + log.debug("MeasurementCollectionJob FIND BY UUID"); + Optional<MeasurementCollectionJob> measurementCollectionJob = measurementCollectionJobRepository.findByUuid(uuid); + return measurementCollectionJob.orElse(null); + } + + @Transactional + public MeasurementCollectionJob createMeasurementCollectionJob(MeasurementCollectionJobFVO measurementCollectionJobFVO){ + log.debug("MeasurementCollectionJob CREATE: {}", measurementCollectionJobFVO); + + MeasurementCollectionJobMapper mapper = Mappers.getMapper(MeasurementCollectionJobMapper.class); + MeasurementCollectionJob mcj = mapper.createMeasurementCollectionJob(measurementCollectionJobFVO); + mcj.setCreationTime( OffsetDateTime.now() ); + mcj.setLastModifiedTime( OffsetDateTime.now()); + mcj = this.measurementCollectionJobRepository.saveAndFlush(mcj); + raiseMCJCreateNotification(mcj); + + return mcj; + } + + @Transactional + public MeasurementCollectionJob updateMeasurementCollectionJob(String uuid, @Valid MeasurementCollectionJobMVO measurementCollectionJobUpdate){ + log.debug("MeasurementCollectionJob UPDATE with UUID: {}", uuid); + + MeasurementCollectionJob measurementCollectionJob = measurementCollectionJobRepository.findByUuid(uuid). + orElseThrow(() -> new IllegalArgumentException("No MeasurementCollectionJob with UUID: " + uuid)); + + ExecutionStateType originalExecutionState = measurementCollectionJob.getExecutionState(); + boolean executionStateChanged = false; + + MeasurementCollectionJobMapper mapper = Mappers.getMapper(MeasurementCollectionJobMapper.class); + measurementCollectionJob = mapper.updateMeasurementCollectionJob(measurementCollectionJobUpdate, measurementCollectionJob); + + measurementCollectionJob.setLastModifiedTime( OffsetDateTime.now()); + measurementCollectionJob = this.measurementCollectionJobRepository.save(measurementCollectionJob); + + + // This may be unnecessary since MeasurementCollectionJobMVO doesn't have the executionState attribute + if ( originalExecutionState!=null) { + executionStateChanged = !originalExecutionState.equals(measurementCollectionJob.getExecutionState()); + } + + if (executionStateChanged) { + raiseMCJExecutionStateChangeNotification(measurementCollectionJob); + } else { + raiseMCJAttributeValueChangeNotification(measurementCollectionJob); + } + + return measurementCollectionJob; + } + + public Void deleteMeasurementCollectionJob(String uuid){ + log.debug("MeasurementCollectionJob DELETE with UUID:{}", uuid); + MeasurementCollectionJob measurementCollectionJob = measurementCollectionJobRepository.findByUuid(uuid) + .orElseThrow(() -> new IllegalArgumentException("No MeasurementCollectionJob with UUID: " + uuid)); + measurementCollectionJobRepository.delete(measurementCollectionJob); + raiseMCJDeleteNotification(measurementCollectionJob); + + return null; + } + + @Transactional(propagation = Propagation.REQUIRES_NEW) + private void raiseMCJCreateNotification(MeasurementCollectionJob mcj){ + // Create the event payload + MeasurementCollectionJobRef ref = new MeasurementCollectionJobRef(); + ref.setId(mcj.getUuid()); + ref.setHref(mcj.getHref()); + ref.setName("MeasurementCollectionJob"); + + + MeasurementCollectionJobCreateEventPayload payload = new MeasurementCollectionJobCreateEventPayload(); + payload.setMeasurementCollectionJob(ref); + + // Create the event + MeasurementCollectionJobCreateEvent event = new MeasurementCollectionJobCreateEvent(); + event.setTitle("MeasurementCollectionJob created"); + event.setDescription("MeasurementCollectionJob with UUID: " + mcj.getUuid() + " has been created"); + event.setEvent(payload); + + routeBuilderEvents.publishEvent(event, mcj.getUuid()); + } + + @Transactional + private void raiseMCJAttributeValueChangeNotification(MeasurementCollectionJob mcj){ + + // Create the event payload + MeasurementCollectionJobAttributeValueChangeEventPayload payload = new MeasurementCollectionJobAttributeValueChangeEventPayload(); + payload.setMeasurementCollectionJob(mcj); + + // Create the event + MeasurementCollectionJobAttributeValueChangeEvent event = new MeasurementCollectionJobAttributeValueChangeEvent(); + event.setTitle("MeasurementCollectionJob attribute value changed"); + event.setDescription("MeasurementCollectionJob with UUID: " + mcj.getUuid() + " has been updated"); + event.setEvent(payload); + + routeBuilderEvents.publishEvent(event, mcj.getUuid()); + } + + @Transactional + private void raiseMCJExecutionStateChangeNotification(MeasurementCollectionJob mcj){ + + // Create the event payload + MeasurementCollectionJobExecutionStateChangeEventPayload payload = new MeasurementCollectionJobExecutionStateChangeEventPayload(); + payload.setMeasurementCollectionJob(mcj); + + // Create the event + MeasurementCollectionJobExecutionStateChangeEvent event = new MeasurementCollectionJobExecutionStateChangeEvent(); + event.setTitle("MeasurementCollectionJob execution state changed"); + event.setDescription("MeasurementCollectionJob with UUID: " + mcj.getUuid() + " execution state has been updated"); + event.setEvent(payload); + + routeBuilderEvents.publishEvent(event, mcj.getUuid()); + } + + @Transactional + private void raiseMCJDeleteNotification(MeasurementCollectionJob mcj){ + + // Create the event payload + MeasurementCollectionJobDeleteEventPayload payload = new MeasurementCollectionJobDeleteEventPayload(); + payload.setMeasurementCollectionJob(mcj); + + // Create the event + MeasurementCollectionJobDeleteEvent event = new MeasurementCollectionJobDeleteEvent(); + event.setTitle("MeasurementCollectionJob deleted"); + event.setDescription("MeasurementCollectionJob with UUID: " + mcj.getUuid() + " execution state has been deleted"); + event.setEvent(payload); + + routeBuilderEvents.publishEvent(event, mcj.getUuid()); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pm628/reposervices/PerformanceIndicatorSpecificationService.java b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/PerformanceIndicatorSpecificationService.java new file mode 100644 index 0000000000000000000000000000000000000000..a543118dba5aa5122cfb27fe13354a3593811c82 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/PerformanceIndicatorSpecificationService.java @@ -0,0 +1,68 @@ +package org.etsi.osl.tmf.pm628.reposervices; + +import org.etsi.osl.tmf.pm628.model.*; +import org.etsi.osl.tmf.pm628.repo.PerformanceIndicatorSpecificationRepository; +import org.mapstruct.factory.Mappers; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +@Service +@Transactional +public class PerformanceIndicatorSpecificationService { + private static final Logger log = LoggerFactory.getLogger(MeasurementCollectionJobService.class); + + private final PerformanceIndicatorSpecificationRepository performanceIndicatorSpecificationRepository; + + @Autowired + public PerformanceIndicatorSpecificationService(PerformanceIndicatorSpecificationRepository performanceIndicatorSpecificationRepository) { + this.performanceIndicatorSpecificationRepository = performanceIndicatorSpecificationRepository; + } + + public List<PerformanceIndicatorSpecification> findAllPerformanceIndicatorSpecifications(){ + log.debug("PerformanceIndicatorSpecificationService: LIST"); + return (List<PerformanceIndicatorSpecification>) performanceIndicatorSpecificationRepository.findAll(); + } + + public PerformanceIndicatorSpecification findPerformanceIndicatorSpecificationByUuid(String uuid){ + log.debug("PerformanceIndicatorSpecification FIND BY UUID"); + Optional<PerformanceIndicatorSpecification> performanceIndicatorSpecification = performanceIndicatorSpecificationRepository.findByUuid(uuid); + return performanceIndicatorSpecification.orElse(null); + } + + public PerformanceIndicatorSpecification createPerformanceIndicatorSpecification(PerformanceIndicatorSpecificationFVO performanceIndicatorSpecificationFVO){ + log.debug("PerformanceIndicatorSpecification CREATE: {}", performanceIndicatorSpecificationFVO); + + PerformanceIndicatorSpecificationMapper mapper = Mappers.getMapper(PerformanceIndicatorSpecificationMapper.class); + PerformanceIndicatorSpecification pis = mapper.createPerformanceIndicatorSpecification(performanceIndicatorSpecificationFVO); + + return performanceIndicatorSpecificationRepository.save(pis); + } + + public PerformanceIndicatorSpecification updatePerformanceIndicatorSpecification(String uuid, PerformanceIndicatorSpecificationMVO performanceIndicatorSpecificationMVO){ + log.debug("PerformanceIndicatorSpecification UPDATE with UUID: {}", uuid); + PerformanceIndicatorSpecification performanceIndicatorSpecification = performanceIndicatorSpecificationRepository.findByUuid(uuid). + orElseThrow(() -> new IllegalArgumentException("No PerformanceIndicatorSpecification with UUID: " + uuid)); + + PerformanceIndicatorSpecificationMapper mapper = Mappers.getMapper(PerformanceIndicatorSpecificationMapper.class); + performanceIndicatorSpecification = mapper.updatePerformanceIndicatorSpecification(performanceIndicatorSpecificationMVO, performanceIndicatorSpecification); + + performanceIndicatorSpecificationRepository.save(performanceIndicatorSpecification); + return performanceIndicatorSpecification; + } + + public Void deletePerformanceIndicatorSpecification(String uuid){ + log.debug("PerformanceIndicatorSpecification DELETE with UUID:{}", uuid); + PerformanceIndicatorSpecification performanceIndicatorSpecification = performanceIndicatorSpecificationRepository.findByUuid(uuid) + .orElseThrow(() -> new IllegalArgumentException("No PerformanceIndicatorSpecification with UUID: " + uuid)); + performanceIndicatorSpecificationRepository.delete(performanceIndicatorSpecification); + + return null; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApiController.java index 540440c66b276040ec915d53f8e9f4c8c6d96198..0a183b76ef9e14ee1c8b2780a5eda15f69c4455f 100644 --- a/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApiController.java +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApiController.java @@ -30,7 +30,7 @@ import jakarta.servlet.http.HttpServletRequest; @jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02:00[Europe/Athens]") @Controller("ListenerApiController622") -@RequestMapping("/productOrder/v4/") +@RequestMapping("/productOrderingManagement/v4/") public class ListenerApiController implements ListenerApi { private final ObjectMapper objectMapper; diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApi.java b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApi.java index b3851c5e55909c7ffb1388ce61e4d191ddbe455d..bd68031c98d66034047611612f2feb58cfb70ec1 100644 --- a/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApi.java +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApi.java @@ -25,6 +25,8 @@ package org.etsi.osl.tmf.po622.api; import java.io.IOException; +import java.security.Principal; +import java.util.Date; import java.util.List; import java.util.Optional; @@ -35,6 +37,7 @@ import org.etsi.osl.tmf.po622.model.ProductOrderUpdate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -79,7 +82,7 @@ public interface ProductOrderApi { produces = { "application/json;charset=utf-8" }, consumes = { "application/json;charset=utf-8" }, method = RequestMethod.POST) - default ResponseEntity<ProductOrder> createProductOrder(@Parameter(description = "The ProductOrder to be created" ,required=true ) @Valid @RequestBody ProductOrderCreate body + default ResponseEntity<ProductOrder> createProductOrder(Principal principal, @Parameter(description = "The ProductOrder to be created" ,required=true ) @Valid @RequestBody ProductOrderCreate body ) { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { if (getAcceptHeader().get().contains("application/json")) { @@ -110,7 +113,7 @@ public interface ProductOrderApi { @RequestMapping(value = "/productOrder/{id}", produces = { "application/json;charset=utf-8" }, method = RequestMethod.DELETE) - default ResponseEntity<Void> deleteProductOrder(@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id + default ResponseEntity<Void> deleteProductOrder(Principal principal,@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id ) { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { } else { @@ -133,9 +136,11 @@ public interface ProductOrderApi { @RequestMapping(value = "/productOrder", produces = { "application/json;charset=utf-8" }, method = RequestMethod.GET) - default ResponseEntity<List<ProductOrder>> listProductOrder(@Parameter(description = "Comma-separated properties to be provided in response") @Valid @RequestParam(value = "fields", required = false) String fields + default ResponseEntity<List<ProductOrder>> listProductOrder(Principal principal,@Parameter(description = "Comma-separated properties to be provided in response") @Valid @RequestParam(value = "fields", required = false) String fields ,@Parameter(description = "Requested index for start of resources to be provided in response") @Valid @RequestParam(value = "offset", required = false) Integer offset -,@Parameter(description = "Requested number of resources to be provided in response") @Valid @RequestParam(value = "limit", required = false) Integer limit +,@Parameter(description = "Requested number of resources to be provided in response") @Valid @RequestParam(value = "limit", required = false) Integer limit, +@Parameter(description = "Requested starttime for start of resources to be provided in response") @Valid @RequestParam(value = "starttime", required = false) Date starttime, +@Parameter(description = "Requested endtime for start of resources to be provided in response") @Valid @RequestParam(value = "endtime", required = false) Date endtime ) { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { if (getAcceptHeader().get().contains("application/json")) { @@ -167,7 +172,7 @@ public interface ProductOrderApi { produces = { "application/json;charset=utf-8" }, consumes = { "application/json;charset=utf-8" }, method = RequestMethod.PATCH) - default ResponseEntity<ProductOrder> patchProductOrder(@Parameter(description = "The ProductOrder to be updated" ,required=true ) @Valid @RequestBody ProductOrderUpdate body + default ResponseEntity<ProductOrder> patchProductOrder(Principal principal,@Parameter(description = "The ProductOrder to be updated" ,required=true ) @Valid @RequestBody ProductOrderUpdate body ,@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id ) { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { @@ -199,7 +204,7 @@ public interface ProductOrderApi { @RequestMapping(value = "/productOrder/{id}", produces = { "application/json;charset=utf-8" }, method = RequestMethod.GET) - default ResponseEntity<ProductOrder> retrieveProductOrder(@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id + default ResponseEntity<ProductOrder> retrieveProductOrder(Principal principal, @Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id ,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields ) { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { @@ -216,5 +221,46 @@ public interface ProductOrderApi { } return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } + + @Operation(summary = "Get a SVG image with product order item services relationship graph", operationId = "getImageProductOrderItemRelationshipGraph", + description = "This operation returns a SVG image with Product order item services relationship graph", tags={ "productOrder", }) +@ApiResponses(value = { + + @ApiResponse(responseCode = "302", description = "Success" ), + //@ApiResponse(responseCode ="200", description = "Success" ), + @ApiResponse(responseCode = "400", description = "Bad Request" ), + @ApiResponse(responseCode = "401", description = "Unauthorized" ), + @ApiResponse(responseCode = "403", description = "Forbidden" ), + @ApiResponse(responseCode = "404", description = "Not Found" ), + @ApiResponse(responseCode = "405", description = "Method Not allowed" ), + @ApiResponse(responseCode = "409", description = "Conflict" ), + @ApiResponse(responseCode = "500", description = "Internal Server Error" ) }) +@RequestMapping(value ="/productOrder/{id}/item/{itemid}/relationship_graph", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) +ResponseEntity<Void> getImageProductOrderItemRelationshipGraph( + @Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the ProductOrderItem",required=true) @PathVariable("itemid") String itemid); + + +@Operation(summary = "Get a SVG image with Product order notes activity graph", operationId = "getImageProductOrderNotesGraph", + description = "This operation returns a SVG image with Product order notes activity graph", tags={ "productOrder", }) +@ApiResponses(value = { + + @ApiResponse(responseCode = "302", description = "Success" ), + //@ApiResponse(responseCode ="200", description = "Success" ), + @ApiResponse(responseCode = "400", description = "Bad Request" ), + @ApiResponse(responseCode = "401", description = "Unauthorized" ), + @ApiResponse(responseCode = "403", description = "Forbidden" ), + @ApiResponse(responseCode = "404", description = "Not Found" ), + @ApiResponse(responseCode = "405", description = "Method Not allowed" ), + @ApiResponse(responseCode = "409", description = "Conflict" ), + @ApiResponse(responseCode = "500", description = "Internal Server Error" ) }) +@RequestMapping(value ="/productOrder/{id}/notes_graph", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) +ResponseEntity<Void> getImageProductOrderNotesGraph( + @Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id); + } diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiController.java b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiController.java index bf80e2db4a7d9f04b08a42f44f00cd8854490ec4..ab307dda35bffd5b26b4632d250536437cc7dd72 100644 --- a/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiController.java +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiController.java @@ -19,37 +19,212 @@ */ package org.etsi.osl.tmf.po622.api; +import java.net.URI; +import java.security.Principal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; import java.util.Optional; import com.fasterxml.jackson.databind.ObjectMapper; - +import org.etsi.osl.model.nfv.UserRoleType; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.po622.model.ProductOrder; +import org.etsi.osl.tmf.po622.model.ProductOrderCreate; +import org.etsi.osl.tmf.po622.model.ProductOrderUpdate; +import org.etsi.osl.tmf.po622.reposervices.ProductOrderRepoService; +import org.etsi.osl.tmf.so641.api.NotFoundException; +import org.etsi.osl.tmf.so641.model.ServiceOrder; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.oauth2.jwt.Jwt; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; - +import io.swagger.v3.oas.annotations.Parameter; import jakarta.servlet.http.HttpServletRequest; -@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02:00[Europe/Athens]") -@Controller +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", + date = "2020-10-30T10:29:21.184964400+02:00[Europe/Athens]") +@Controller("ProductOrderApiController622") @RequestMapping("/productOrderingManagement/v4/") public class ProductOrderApiController implements ProductOrderApi { - private final ObjectMapper objectMapper; + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + @Value("${kroki.serverurl}") + private String KROKI_SERVERURL = ""; + + @Autowired + ProductOrderRepoService productOrderRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public ProductOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + @Override + public ResponseEntity<ProductOrder> createProductOrder(Principal principal, + @Parameter(description = "The ProductOrder to be created", + required = true) @Valid @RequestBody ProductOrderCreate productOrder) { + + try { + // Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + // SecurityContextHolder.setContext( (SecurityContext) attr ); + + + log.info("authentication= " + principal.toString()); + String extInfo = null; + try { + + + if (principal instanceof JwtAuthenticationToken) { + + JwtAuthenticationToken pr = (JwtAuthenticationToken) principal; + + Jwt lp = (Jwt) pr.getPrincipal(); + extInfo = lp.getClaimAsString("email"); + log.debug("extInfo= " + extInfo); + + productOrder.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser(principal.getName(), + // user.getId()+"", + principal.getName(), UserPartRoleType.REQUESTER, extInfo, + productOrder.getRelatedParty())); + } else if (principal instanceof UsernamePasswordAuthenticationToken) { + productOrder.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser(principal.getName(), + // user.getId()+"", + principal.getName(), UserPartRoleType.REQUESTER, extInfo, + productOrder.getRelatedParty())); + } + + + } finally { + + } - private final HttpServletRequest request; - @org.springframework.beans.factory.annotation.Autowired - public ProductOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = request; + + ProductOrder c = productOrderRepoService.addProductOrder(productOrder); + + return new ResponseEntity<ProductOrder>(c, HttpStatus.OK); + + + } catch (NotFoundException e) { + log.error("Couldn't create Service Order. ", e); + return new ResponseEntity<ProductOrder>(HttpStatus.BAD_REQUEST); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<ProductOrder>(HttpStatus.INTERNAL_SERVER_ERROR); } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')") + public ResponseEntity<Void> deleteProductOrder(Principal principal, String id) { - @Override - public Optional<ObjectMapper> getObjectMapper() { - return Optional.ofNullable(objectMapper); + try { + return new ResponseEntity<Void>(productOrderRepoService.deleteByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR); } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')") + public ResponseEntity<List<ProductOrder>> listProductOrder(Principal principal, + @Valid String fields, @Valid Integer offset, @Valid Integer limit, @Valid Date starttime, + @Valid Date endtime) { + try { + + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + log.debug("principal= " + principal.toString()); + + log.debug("principal ROLE_ADMIN = " + authentication.getAuthorities() + .contains(new SimpleGrantedAuthority(UserRoleType.ROLE_ADMIN.getValue()))); + log.debug("principal ROLE_NFV_DEVELOPER = " + authentication.getAuthorities() + .contains(new SimpleGrantedAuthority(UserRoleType.ROLE_NFV_DEVELOPER.getValue()))); + log.debug("principal ROLE_EXPERIMENTER = " + authentication.getAuthorities() + .contains(new SimpleGrantedAuthority(UserRoleType.ROLE_EXPERIMENTER.getValue()))); + + if (authentication.getAuthorities() + .contains(new SimpleGrantedAuthority(UserRoleType.ROLE_ADMIN.getValue()))) { + + return new ResponseEntity<List<ProductOrder>>( + productOrderRepoService.findAll(fields, new HashMap<>(), starttime, endtime), + HttpStatus.OK); + } else { + return new ResponseEntity<List<ProductOrder>>( + productOrderRepoService.findAll(principal.getName(), UserPartRoleType.REQUESTER), + HttpStatus.OK); + } - @Override - public Optional<HttpServletRequest> getRequest() { - return Optional.ofNullable(request); + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<List<ProductOrder>>(HttpStatus.INTERNAL_SERVER_ERROR); } + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + public ResponseEntity<ProductOrder> patchProductOrder(Principal principal, + @Valid ProductOrderUpdate body, String id) { + ProductOrder c = productOrderRepoService.updateProductOrder(id, body); + + return new ResponseEntity<ProductOrder>(c, HttpStatus.OK); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + public ResponseEntity<ProductOrder> retrieveProductOrder(Principal principal, String id, + @Valid String fields) { + try { + + return new ResponseEntity<ProductOrder>( productOrderRepoService.findByUuid( id ), HttpStatus.OK); + } catch ( Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<ProductOrder>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + public ResponseEntity<Void> getImageProductOrderItemRelationshipGraph(String id, String itemid) { + String encodedDiagram = + productOrderRepoService.getImageProductOrderItemRelationshipGraph(id, itemid); + + // consider redirect to kroki..id + return ResponseEntity.status(HttpStatus.FOUND) + .location(URI.create(KROKI_SERVERURL + "/blockdiag/svg/" + encodedDiagram)).build(); + // return null; + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + public ResponseEntity<Void> getImageProductOrderNotesGraph(String id) { + String encodedDiagram = productOrderRepoService.getImageProductOrderNotesGraph(id); + // consider redirect to kroki..id + return ResponseEntity.status(HttpStatus.FOUND) + .location(URI.create(KROKI_SERVERURL + "/actdiag/svg/" + encodedDiagram)).build(); + } } diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..23dbc57a33d948b7bc9ae6d01f0da12a7bbafb3c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilder.java @@ -0,0 +1,101 @@ +package org.etsi.osl.tmf.po622.api; + +import java.util.Map; +import org.apache.camel.LoggingLevel; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.po622.model.ProductOrderCreate; +import org.etsi.osl.tmf.po622.model.ProductOrderUpdate; +import org.etsi.osl.tmf.po622.reposervices.ProductOrderRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Configuration +//@RefreshScope +@Component +public class ProductOrderApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ProductOrderApiRouteBuilder.class.getName()); + + @Value("${CATALOG_GET_PRODUCTORDER_BY_ID}") + private String CATALOG_GET_PRODUCTORDER_BY_ID = ""; + + @Value("${CATALOG_GET_PRODUCTORDERS}") + private String CATALOG_GET_PRODUCTORDERS = ""; + + @Value("${CATALOG_GET_INITIAL_PRODUCTORDERS_IDS}") + private String CATALOG_GET_INITIAL_PRODUCTORDERS_IDS = ""; + + @Value("${CATALOG_GET_PRODUCTORDER_IDS_BY_STATE}") + private String CATALOG_GET_PRODUCTORDER_IDS_BY_STATE = ""; + + @Value("${CATALOG_UPD_PRODUCTORDER_BY_ID}") + private String CATALOG_UPD_PRODUCTORDER_BY_ID = ""; + + @Value("${CATALOG_ADD_PRODUCTORDER}") + private String CATALOG_ADD_PRODUCTORDER = ""; + + + @Value("${GET_USER_BY_USERNAME}") + private String GET_USER_BY_USERNAME = ""; + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private ProducerTemplate template; + + @Autowired + ProductOrderRepoService productOrderRepoService; + + @Autowired + private CentralLogger centralLogger; + + + @Override + public void configure() throws Exception { + from(CATALOG_GET_PRODUCTORDERS).log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTORDERS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean(productOrderRepoService, "findAllParamsJsonOrderIDs").convertBodyTo(String.class); + + +from(CATALOG_GET_INITIAL_PRODUCTORDERS_IDS) + .log(LoggingLevel.INFO, log, CATALOG_GET_INITIAL_PRODUCTORDERS_IDS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").setBody(constant("{\"state\":\"INITIAL\"}")).unmarshal() + .json(JsonLibrary.Jackson, Map.class, true).bean(productOrderRepoService, "findAllParamsJsonOrderIDs") + .convertBodyTo(String.class); + +from(CATALOG_GET_PRODUCTORDER_IDS_BY_STATE) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTORDER_IDS_BY_STATE + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").setBody(simple("{\"state\":\"${header.orderstate}\"}")) + .unmarshal().json(JsonLibrary.Jackson, Map.class, true) + .bean(productOrderRepoService, "findAllParamsJsonOrderIDs").convertBodyTo(String.class); + +from(CATALOG_GET_PRODUCTORDER_BY_ID) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTORDER_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean(productOrderRepoService, "getProductOrderEagerAsString").convertBodyTo(String.class); + +from(CATALOG_UPD_PRODUCTORDER_BY_ID) + .log(LoggingLevel.INFO, log, CATALOG_UPD_PRODUCTORDER_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").unmarshal() + .json(JsonLibrary.Jackson, ProductOrderUpdate.class, true) + .bean(productOrderRepoService, "updateProductOrder(${header.orderid}, ${body})"); + + +from(CATALOG_ADD_PRODUCTORDER) + .log(LoggingLevel.INFO, log, CATALOG_ADD_PRODUCTORDER + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").unmarshal() + .json(JsonLibrary.Jackson, ProductOrderCreate.class, true) + .bean(productOrderRepoService, "addProductOrderReturnEager(${body})") + .convertBodyTo(String.class); //creates back a response + } + + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilderEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..8343d3da1c62d37fbc0cd518416aeadc38e2fc83 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilderEvents.java @@ -0,0 +1,108 @@ +package org.etsi.osl.tmf.po622.api; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.common.model.Notification; +import org.etsi.osl.tmf.po622.model.ProductOrderAttributeValueChangeNotification; +import org.etsi.osl.tmf.po622.model.ProductOrderCreateNotification; +import org.etsi.osl.tmf.po622.model.ProductOrderDeleteNotification; +import org.etsi.osl.tmf.po622.model.ProductOrderStateChangeNotification; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Configuration +// @RefreshScope +@Component +public class ProductOrderApiRouteBuilderEvents extends RouteBuilder { + + private static final transient Log logger = + LogFactory.getLog(ProductOrderApiRouteBuilderEvents.class.getName()); + + + + @Value("${EVENT_PRODUCT_ORDER_CREATE}") + private String EVENT_PRODUCT_ORDER_CREATE = ""; + + @Value("${EVENT_PRODUCT_ORDER_STATE_CHANGED}") + private String EVENT_PRODUCT_ORDER_STATE_CHANGED = ""; + + @Value("${EVENT_PRODUCT_ORDER_DELETE}") + private String EVENT_PRODUCT_ORDER_DELETE = ""; + + @Value("${EVENT_PRODUCT_ORDER_ATTRIBUTE_VALUE_CHANGED}") + private String EVENT_PRODUCT_ORDER_ATTRIBUTE_VALUE_CHANGED = ""; + + + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private ProducerTemplate template; + + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + + + } + + /** + * @param n + */ + @Transactional + public void publishEvent(final Notification n, final String objId) { + n.setEventType(n.getClass().getName()); + logger.info("will send Event for type " + n.getEventType()); + try { + String msgtopic = ""; + + if (n instanceof ProductOrderCreateNotification) { + msgtopic = EVENT_PRODUCT_ORDER_CREATE; + } else if (n instanceof ProductOrderStateChangeNotification) { + msgtopic = EVENT_PRODUCT_ORDER_STATE_CHANGED; + } else if (n instanceof ProductOrderDeleteNotification) { + msgtopic = EVENT_PRODUCT_ORDER_DELETE; + } else if (n instanceof ProductOrderAttributeValueChangeNotification) { + msgtopic = EVENT_PRODUCT_ORDER_ATTRIBUTE_VALUE_CHANGED; + } + Map<String, Object> map = new HashMap<>(); + map.put("eventid", n.getEventId()); + map.put("objId", objId); + + String apayload = toJsonString(n); + template.sendBodyAndHeaders(msgtopic, apayload, map); + + + centralLogger.log(CLevel.INFO, apayload, compname); + + } catch (Exception e) { + e.printStackTrace(); + logger.error("Cannot send Event . " + e.getMessage()); + } + } + + + static String toJsonString(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString(object); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/repo/ProductOrderRepository.java b/src/main/java/org/etsi/osl/tmf/po622/repo/ProductOrderRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..ae19cea2051edbc0248c9e6b581789e43c765714 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/repo/ProductOrderRepository.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.po622.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.po622.model.ProductOrder; +import org.etsi.osl.tmf.po622.model.ProductOrderStateType; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface ProductOrderRepository extends CrudRepository<ProductOrder, Long>, PagingAndSortingRepository<ProductOrder, Long> { + + + Optional<ProductOrder> findByUuid(String id); + + Iterable<ProductOrder> findByState( ProductOrderStateType state); + @Query("SELECT por FROM ProductOrder por JOIN FETCH por.relatedParty rp WHERE rp.name = ?1 AND rp.role = ?2 ORDER BY por.orderDate DESC") + Iterable<ProductOrder> findByRolenameAndRoleType(String rolename, UserPartRoleType requester); + @Query("SELECT por FROM ProductOrder por JOIN FETCH por.relatedParty rp WHERE rp.name = ?1") + Iterable<ProductOrder> findByRolename(String rolename); + + List<ProductOrder> findByOrderByOrderDateDesc(); + + @Query("SELECT por FROM ProductOrder por JOIN FETCH por.relatedParty rp ORDER BY por.orderDate DESC") + List<ProductOrder> findAllOptimized(); + + + + @Query("SELECT por FROM ProductOrder por JOIN FETCH por.note an " + + "WHERE por.uuid = ?1 " + + "ORDER BY an.date ASC") + Optional<ProductOrder> findNotesOfProdOrder(String id); +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java b/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..2ae7aa07aac5b7440c131f256216f9fddbb52666 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java @@ -0,0 +1,707 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.po622.reposervices; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.common.model.service.ServiceRef; +import org.etsi.osl.tmf.pcm620.model.ProductOffering; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingRef; +import org.etsi.osl.tmf.pcm620.model.ProductSpecification; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationRef; +import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingRepoService; +import org.etsi.osl.tmf.pcm620.reposervices.ProductSpecificationRepoService; +import org.etsi.osl.tmf.po622.api.ProductOrderApiRouteBuilderEvents; +import org.etsi.osl.tmf.po622.model.OrderItemActionType; +import org.etsi.osl.tmf.po622.model.ProductOrder; +import org.etsi.osl.tmf.po622.model.ProductOrderAttributeValueChangeEvent; +import org.etsi.osl.tmf.po622.model.ProductOrderAttributeValueChangeNotification; +import org.etsi.osl.tmf.po622.model.ProductOrderCreate; +import org.etsi.osl.tmf.po622.model.ProductOrderCreateEvent; +import org.etsi.osl.tmf.po622.model.ProductOrderCreateNotification; +import org.etsi.osl.tmf.po622.model.ProductOrderItem; +import org.etsi.osl.tmf.po622.model.ProductOrderItemStateType; +import org.etsi.osl.tmf.po622.model.ProductOrderMapper; +import org.etsi.osl.tmf.po622.model.ProductOrderStateChangeEvent; +import org.etsi.osl.tmf.po622.model.ProductOrderStateChangeNotification; +import org.etsi.osl.tmf.po622.model.ProductOrderStateType; +import org.etsi.osl.tmf.po622.model.ProductOrderUpdate; +import org.etsi.osl.tmf.po622.repo.ProductOrderRepository; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.etsi.osl.tmf.so641.api.NotFoundException; +import org.etsi.osl.tmf.so641.reposervices.ServiceOrderRepoService; +import org.etsi.osl.tmf.util.KrokiClient; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.query.Query; +import org.hibernate.transform.ResultTransformer; +import org.mapstruct.factory.Mappers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.PersistenceContext; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Service +public class ProductOrderRepoService { + + private static final transient Log logger = + LogFactory.getLog(ProductOrderRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ProductOrderRepository productOrderRepo; + + + @Autowired + ProductSpecificationRepoService productSpecificationRepoService; + + @Autowired + ProductOfferingRepoService productOfferingRepoService; + + + @Autowired + ProductOrderApiRouteBuilderEvents productOrderApiRouteBuilder; + + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + ServiceOrderRepoService serviceOrderRepoService; + + private SessionFactory sessionFactory; + + @PersistenceContext EntityManager entityManager; + + @Autowired + public ProductOrderRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + @Transactional + public List<ProductOrder> findAll() { + + // return (List<ProductOrder>) this.productOrderRepo.findAll(); + // return (List<ProductOrder>) this.productOrderRepo.findByOrderByOrderDateDesc(); + return (List<ProductOrder>) this.productOrderRepo.findAllOptimized(); + } + + public Void deleteByUuid(String id) { + + Optional<ProductOrder> optso = this.productOrderRepo.findByUuid(id); + ProductOrder so = optso.get(); + if ( so == null ) { + return null; + } + + this.productOrderRepo.delete(so); + return null; +} + + + public List<ProductOrder> findAllParams(Map<String, String> allParams) { + logger.info("findAll with params:" + allParams.toString()); + if ( ( allParams !=null) && allParams.get("state") !=null) { + ProductOrderStateType state = ProductOrderStateType.fromValue( allParams.get("state") ); + logger.info("find by state:" + state ); + return (List<ProductOrder>) this.productOrderRepo.findByState(state); + }else { + return findAll(); + } + } + + + public String findAllParamsJsonOrderIDs(Map<String, String> allParams) throws JsonProcessingException { + + List<ProductOrder> lso = findAllParams(allParams); + ArrayList<String> oids = new ArrayList<>(); + for (ProductOrder object : lso) { + oids.add(object.getId()); + } + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString( oids ); + + return res; + } + + public String addProductOrderReturnEager(@Valid ProductOrderCreate pOrderCreate) { + try { + ProductOrder so = this.addProductOrder(pOrderCreate); + return this.getProductOrderEagerAsString( so.getUuid()); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; +} + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List findAll(@Valid String fields, Map<String, String> allParams, @Valid Date starttime, @Valid Date endtime) + throws UnsupportedEncodingException { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List<ProductOrder> alist = null; + try { + String sql = "SELECT " + + "por.uuid as uuid," + + "por.orderDate as orderDate," + + "por.requestedStartDate as requestedStartDate," + + "por.requestedCompletionDate as requestedCompletionDate," + + "por.expectedCompletionDate as expectedCompletionDate," + + "por.state as state," + + "por.type as type," + + "rp.uuid as relatedParty_uuid," + + "rp.name as relatedParty_name"; + + if (fields != null && fields.length()>0 ) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", sor." + f + " as " + f ; + } + + } + sql += " FROM ProductOrder por " + + "JOIN por.relatedParty rp "; + + if (allParams.size() > 0) { + sql += " WHERE rp.role = 'REQUESTER' AND "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + } else { + sql += " WHERE rp.role = 'REQUESTER' "; + } + + if ( starttime != null ) { + sql += " AND por.orderDate >= :param1"; + + } + if ( endtime != null ) { + sql += " AND por.expectedCompletionDate <= :param2"; + } + + sql += " ORDER BY por.orderDate DESC"; + + Query query = session.createQuery( sql ); + if ( starttime != null ) { + query.setParameter("param1", starttime.toInstant().atOffset(ZoneOffset.UTC) ); + } + if ( endtime != null ) { + query.setParameter("param2", endtime.toInstant().atOffset(ZoneOffset.UTC) ); + } + + List<Object> mapaEntity = query + .setResultTransformer( new ResultTransformer() { + + @Override + public Object transformTuple(Object[] tuple, String[] aliases) { + Map<String, Object> result = new LinkedHashMap<String, Object>(tuple.length); + for (int i = 0; i < tuple.length; i++) { + String alias = aliases[i]; + if (alias.equals("uuid")) { + result.put("id", tuple[i]); + } + if (alias.equals("type")) { + alias = "@type"; + } + if (alias.equals("relatedParty_name")) { + if ( result.get( "relatedParty" ) == null ) { + result.put("relatedParty", new ArrayList<Object>() ) ; + } + ArrayList< Object> rpList = (ArrayList< Object>) result.get( "relatedParty" ); + LinkedHashMap<String, Object> rp = new LinkedHashMap<String, Object>(); + rp.put("name", tuple[i]); + rp.put("role", "REQUESTER" ); + rpList.add(rp); + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + + public List<ProductOrder> findAll(String rolename, UserPartRoleType requester) { + return (List<ProductOrder>) this.productOrderRepo.findByRolename(rolename); + } + + + @Transactional + public ProductOrder addProductOrder(@Valid ProductOrderCreate productOrderCreate) throws NotFoundException { + + // Ensure that all Product Specifications exist + List <ProductOrderItem> productOrderItemList = productOrderCreate.getProductOrderItem(); + for (ProductOrderItem productOrderItem: productOrderItemList) { + + @Valid + ProductOfferingRef pOfferf = productOrderItem.getProductOffering(); + + if (pOfferf==null) { + throw new NotFoundException(400, "There is no ProductOfferingRef in Product Order Create request"); + } + + ProductOffering pOffer = productOfferingRepoService.findByUuid( pOfferf.getId() ); + @Valid + ProductSpecificationRef prodSpec = pOffer.getProductSpecification(); + String prodSpecificationId = prodSpec.getId(); + + ProductSpecification prodSpecification = productSpecificationRepoService.findByUuid(prodSpecificationId); + + if (prodSpecification == null) + throw new NotFoundException(400, "There is no Product Specification with Id: " + prodSpecificationId); + } + + + ProductOrder so = new ProductOrder(); + so.setOrderDate(OffsetDateTime.now(ZoneOffset.UTC)); + so.setCategory(productOrderCreate.getCategory()); + so.setDescription(productOrderCreate.getDescription()); + so.setExternalId(productOrderCreate.getExternalId()); + so.setNotificationContact(productOrderCreate.getNotificationContact()); + so.priority(productOrderCreate.getPriority()); + so.requestedCompletionDate(productOrderCreate.getRequestedCompletionDate()); + so.requestedStartDate(productOrderCreate.getRequestedStartDate() ); + so.setExpectedCompletionDate( productOrderCreate.getRequestedCompletionDate() ); //this is by default + if (productOrderCreate.getNote() != null) { + so.getNote().addAll(productOrderCreate.getNote()); + } + + if ( productOrderCreate.getState() != null ) { + so.setState( productOrderCreate.getState() ); + } else { + so.setState( ProductOrderStateType.INITIAL ); + } + + + + + + + boolean allAcknowledged = false; + if (productOrderCreate.getProductOrderItem() != null) { + allAcknowledged = true; + so.getProductOrderItem().addAll(productOrderCreate.getProductOrderItem()); + for (ProductOrderItem soi : so.getProductOrderItem()) { + if ( ! soi.getState().equals( ProductOrderItemStateType.ACKNOWLEDGED )) { + allAcknowledged = false; + } + } + } + + if (productOrderCreate.getRelatedParty() != null) { + so.getRelatedParty().addAll(productOrderCreate.getRelatedParty()); + } + + + Note noteItem = new Note(); + noteItem.setText("Product Order " + ProductOrderStateType.INITIAL); + noteItem.setAuthor("PO622API-addProductOrder"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + so.addNoteItem(noteItem); + + so = this.productOrderRepo.save(so); + + if (allAcknowledged) { //in the case were order items are automatically acknowledged + so.setState( ProductOrderStateType.ACKNOWLEDGED ); + noteItem = new Note(); + noteItem.setText("Product Order " + ProductOrderStateType.ACKNOWLEDGED); + noteItem.setAuthor("PO622API-addProductOrder"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + so.addNoteItem(noteItem); + + so = this.productOrderRepo.save(so); + + } + + + + raisePOCreateNotification(so); + + return so; + } + + @Transactional + public ProductOrder updateProductOrder(String id, @Valid ProductOrderUpdate prodOrderUpd) { + + logger.info("Will updateProductOrder:" + id); + + ProductOrder po = this.findByUuid(id); + + boolean stateChanged = false; + if ( prodOrderUpd.getState()!= null ) { + stateChanged = po.getState() != prodOrderUpd.getState(); + } + boolean expectedCompletionDateChanged = false; + + ProductOrderMapper mapper = Mappers.getMapper( ProductOrderMapper.class ); + po = mapper.updateProductOrder(po, prodOrderUpd); + + + if ( prodOrderUpd.getState() != null ) { + po.state( prodOrderUpd.getState() ); + } + + if ( prodOrderUpd.getDescription() != null ) { + po.setDescription( prodOrderUpd.getDescription() ); + } + + + + if ( po.getState().equals( ProductOrderStateType.COMPLETED )) { + po.setCompletionDate( OffsetDateTime.now(ZoneOffset.UTC)); + } + + + if ( prodOrderUpd.getExpectedCompletionDate()!= null ) { + expectedCompletionDateChanged = true; + } + + if ( stateChanged ) { + Note noteItem = new Note(); + noteItem.setText("Product Order " + po.getState() ); + noteItem.setAuthor("PO622API-stateChanged"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + po.addNoteItem(noteItem); + } + + // Update each Service's end date to the updated Service Order's expected completion date + if (expectedCompletionDateChanged) { + List<String> services = serviceRepoService.getServicesFromOrderID(id); + + for (String serviceId : services) { + logger.debug("Will delegate updated Product Order expected completion date " + + po.getExpectedCompletionDate() + " to service with id = " + serviceId); + + @Valid + ServiceUpdate servUpd = new ServiceUpdate(); + servUpd.setEndDate(po.getExpectedCompletionDate()); + serviceRepoService.updateService(serviceId, servUpd, false, null, null); + } + } + + po = this.productOrderRepo.save(po); + if (stateChanged) { + raisePOStateChangedNotification(po); + } else { + raisePOAttributeValueChangedNotification(po); + } + + return po; + + } + + + @Transactional + public ProductOrder findByUuid(String id) { + Optional<ProductOrder> optionalCat = this.productOrderRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + + @Transactional + private void raisePOCreateNotification(ProductOrder so) { + + ProductOrderCreateNotification n = new ProductOrderCreateNotification(); + ProductOrderCreateEvent event = new ProductOrderCreateEvent(); + event.getEvent().productOrder( so ); + n.setEvent(event ); + productOrderApiRouteBuilder.publishEvent(n, so.getId()); + + + } + + @Transactional + private void raisePOStateChangedNotification(ProductOrder so) { + ProductOrderStateChangeNotification n = new ProductOrderStateChangeNotification(); + ProductOrderStateChangeEvent event = new ProductOrderStateChangeEvent(); + //event.serviceOrder( getServiceORderEager( so.getId()) ); + event.getEvent().productOrder( so ); + n.setEvent(event ); + productOrderApiRouteBuilder.publishEvent(n, so.getId()); + + } + + @Transactional + private void raisePOAttributeValueChangedNotification(ProductOrder so) { + ProductOrderAttributeValueChangeNotification n = new ProductOrderAttributeValueChangeNotification(); + ProductOrderAttributeValueChangeEvent event = new ProductOrderAttributeValueChangeEvent(); + event.getEvent().productOrder( so ); + n.setEvent(event ); + productOrderApiRouteBuilder.publishEvent(n, so.getId()); + + } + + @Transactional + public ProductOrder getProductOrderEager(String id) { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + + try { + ProductOrder s = null; + try { + s = (ProductOrder) session.get(ProductOrder.class, id); + if (s == null) { + return this.findByUuid(id);// last resort + } + + Hibernate.initialize(s.getRelatedParty()); + Hibernate.initialize(s.getProductOrderItem() ); + Hibernate.initialize(s.getNote() ); + Hibernate.initialize(s.getChannel()); + for (ProductOrderItem soi : s.getProductOrderItem()) { + if ( soi.getProduct() != null ) { + Hibernate.initialize( soi.getProduct().getProductCharacteristic() ); + } + Hibernate.initialize( soi.getProductOffering() ); + } + + tx.commit(); + } finally { + session.close(); + } + + return s; + } catch (Exception e) { + e.printStackTrace(); + } + + session.close(); + return null; + + +} + + @Transactional + public String getProductOrderEagerAsString(String id) throws JsonProcessingException { + ProductOrder s = this.getProductOrderEager(id); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString(s); + + return res; + } + + + public String getImageProductOrderItemRelationshipGraph(String id, @NotNull String itemid) { + ProductOrder so = this.findByUuid(id); + String charvalue = null; + if ( so!=null) { + for (ProductOrderItem soiOrigin : so.getProductOrderItem()) { + if ( soiOrigin.getId().equals(itemid)) { + charvalue = createItemRelationshipGraphNotation( soiOrigin ); + + } + + } + } + + return KrokiClient.encodedGraph( charvalue ); + } + + + private String createItemRelationshipGraphNotation(ProductOrderItem soiOrigin) { + String result = getPOItemGraphNotation(soiOrigin, 0 ); + result = "blockdiag {" + + "default_textcolor = white;\r\n" + + "default_fontsize = 12;\r\n" + + "\r\n" + result + "}"; + return result; + } + + + private String getPOItemGraphNotation(ProductOrderItem soiOrigin, int depth) { + String result = ""; + if (depth>10 || soiOrigin.getProduct()==null) { + return result; + } + for (ServiceRef specRel : soiOrigin.getProduct().getRealizingService() ) { + if ( !soiOrigin.getProduct().getName().equals( specRel.getName()) ) { + result += "\""+ soiOrigin.getProduct().getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; + result += "\""+ specRel.getId() + "\""+ " [label =\""+ specRel.getName() +"\", color = \"#2596be\"]; \r\n"; + org.etsi.osl.tmf.sim638.model.Service aService= serviceRepoService.findByUuid( specRel.getId() ); + if ( aService!= null) { + result += getServiceGraphNotation( aService,0 ); + } + } + + } + + + result += "\""+ soiOrigin.getProduct().getId() + "\""+ " [label = \""+ soiOrigin.getProduct().getName() +"\", color = \"#2596be\"]; \r\n"; + return result; + } + + + private String getServiceGraphNotation(org.etsi.osl.tmf.sim638.model.Service aService, int depth) { + String result = ""; + if (depth>10) { + return result; + } + for (ServiceRef specRel : aService.getSupportingService() ) { + result += "\""+ aService.getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; + result += "\""+ specRel.getId() + "\""+ " [label = \"" + specRel.getName() + "\", color = \"#2596be\"];\r\n"; + + for (ResourceRef resRel : aService.getSupportingResource()) { + + result += "\""+ aService.getId() + "\""+ " -> " + "\""+ resRel.getId() + "\""+ ";\r\n"; + result += "\""+ resRel.getId() + "\""+ " [ label = \"" + resRel.getName() +"\", shape = roundedbox, color = \"#e28743\"]; \r\n"; + + } + + } + + + return result; + } + + + public String getImageProductOrderNotesGraph(String id) { + + @Data + class ALane{ + public ALane(String author) { + this.name =author; + } + String name = ""; + List<Note> boxes = new ArrayList<Note>(); + } + + Map <String, ALane> lanes = new HashMap<>(); + String charvalue = ""; + Optional<ProductOrder> optionalCat = this.productOrderRepo.findNotesOfProdOrder(id); + if ( optionalCat.isPresent() ) { + + ProductOrder so = optionalCat.get(); + List<Note> notes = so.getNote() + .stream() + .sorted( (a, b) -> a.getDate().compareTo(b.getDate()) ) + .collect(Collectors.toList()); + + for (Note anote : notes ) { + if ( charvalue.length() > 0 ) { + charvalue += " -> "; + } + charvalue += "\""+ anote.getUuid() + "\"" ; + + if ( lanes.get( anote.getAuthor()) == null) { + lanes.put( anote.getAuthor() , new ALane( anote.getAuthor() )); + } + + lanes.get( anote.getAuthor()).boxes.add( anote); + + } + + } + + for (String lane : lanes.keySet()) { + charvalue += "lane " + lanes.get(lane).name + " {\r\n"; + for ( Note aNote : lanes.get(lane).boxes) { + charvalue += aNote.getUuid() +" [label = \"" + aNote.getDateString() + "\r\n "+ aNote.getText() +"\", color = \"#2596be\"]\r\n"; + } + charvalue += "}\r\n"; + } + + charvalue = "actdiag {" + + "default_textcolor = white;\r\n" + + "default_fontsize = 9;\r\n" + + "\r\n" + charvalue + "}\r\n"; + return KrokiClient.encodedGraph( charvalue ); + + +} + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..c4fa93b1639d29fec025d4940d5c45acf9a9fcb2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ApiException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2024 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ + +package org.etsi.osl.tmf.ram702.api; + +public class ApiException extends Exception{ + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..e1e9261fc3eb880715710693e8216f6cd261ede9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ApiOriginFilter.java @@ -0,0 +1,50 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2024 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ + +package org.etsi.osl.tmf.ram702.api; + +import java.io.IOException; + +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; + +public class ApiOriginFilter implements jakarta.servlet.Filter { + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..8b8bfb850f1492cd8d6bfcb44971b219f60a925e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ApiResponseMessage.java @@ -0,0 +1,88 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2024 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ + +package org.etsi.osl.tmf.ram702.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/ram702/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..92eaec8e60eced6e7f12519722005f4ec40b6896 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/NotFoundException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2024 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ + +package org.etsi.osl.tmf.ram702.api; + +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApi.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..37ef568250b34ac524f54bcd94c1d0d6b89a494b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApi.java @@ -0,0 +1,319 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2024 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ + +package org.etsi.osl.tmf.ram702.api; + +import java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@Tag(name = "resource", description = "The resource Activation API") +public interface ResourceActivationApi { + + public static final String RESOURCE_JSON_RESPONSE = "{}"; + + public static final String RESOURCE_LIST_JSON_RESPONSE = "[{}]"; + + Logger log = LoggerFactory.getLogger(ResourceActivationApi.class); + + default Optional<ObjectMapper> getObjectMapper() { + return Optional.empty(); + } + + default Optional<HttpServletRequest> getRequest() { + return Optional.empty(); + } + + default Optional<String> getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + + @Operation( + summary = "Creates a Resource", + operationId = "createResource", + description = "This operation creates a Resource entity.", + tags = {"resource"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Created"), + @ApiResponse(responseCode = "400", description = "Bad Request"), + @ApiResponse(responseCode = "401", description = "Unauthorized"), + @ApiResponse(responseCode = "403", description = "Forbidden"), + @ApiResponse(responseCode = "405", description = "Method Not allowed"), + @ApiResponse(responseCode = "409", description = "Conflict"), + @ApiResponse(responseCode = "500", description = "Internal Server Error") + }) + @RequestMapping( + value = "/resource", + produces = {"application/json;charset=utf-8"}, + consumes = {"application/json;charset=utf-8"}, + method = RequestMethod.POST + ) + default ResponseEntity<Resource> createResource( + Principal principal, + @Parameter(description = "The Resource to be created", required = true) + @Valid @RequestBody ResourceCreate body + ) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>( + getObjectMapper().get().readValue( + RESOURCE_JSON_RESPONSE, Resource.class + ), + HttpStatus.NOT_IMPLEMENTED + ); + } catch (IOException e) { + log.error( + "Couldn't serialize response for content type application/json", e + ); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourceActivationApi interface so no example is generated" + ); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation( + summary = "Deletes a Resource", + operationId = "deleteResource", + description = "This operation deletes a Resource entity.", + tags = {"resource"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "204", description = "Deleted"), + @ApiResponse(responseCode = "400", description = "Bad Request"), + @ApiResponse(responseCode = "401", description = "Unauthorized"), + @ApiResponse(responseCode = "403", description = "Forbidden"), + @ApiResponse(responseCode = "404", description = "Not Found"), + @ApiResponse(responseCode = "405", description = "Method Not allowed"), + @ApiResponse(responseCode = "409", description = "Conflict"), + @ApiResponse(responseCode = "500", description = "Internal Server Error") + }) + @RequestMapping( + value = "/resource/{id}", + produces = {"application/json;charset=utf-8"}, + method = RequestMethod.DELETE + ) + default ResponseEntity<Void> deleteResource( + @Parameter(description = "Identifier of the Resource", required = true) + @PathVariable("id") String id + ) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + // Implementation goes here + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourceActivationApi interface so no example is generated" + ); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation( + summary = "List or find Resource objects", + operationId = "listResource", + description = "This operation lists or finds Resource entities.", + tags = {"resource"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "400", description = "Bad Request"), + @ApiResponse(responseCode = "401", description = "Unauthorized"), + @ApiResponse(responseCode = "403", description = "Forbidden"), + @ApiResponse(responseCode = "404", description = "Not Found"), + @ApiResponse(responseCode = "405", description = "Method Not allowed"), + @ApiResponse(responseCode = "409", description = "Conflict"), + @ApiResponse(responseCode = "500", description = "Internal Server Error") + }) + @RequestMapping( + value = "/resource", + produces = {"application/json;charset=utf-8"}, + method = RequestMethod.GET + ) + default ResponseEntity<List<Resource>> listResource( + Principal principal, + @Parameter(description = "Comma-separated properties to be provided in response") + @Valid @RequestParam(value = "fields", required = false) String fields, + @Parameter(description = "Requested index for start of resources to be provided in response") + @Valid @RequestParam(value = "offset", required = false) Integer offset, + @Parameter(description = "Requested number of resources to be provided in response") + @Valid @RequestParam(value = "limit", required = false) Integer limit, + @Parameter(hidden = true) @Valid @RequestParam Map<String, String> allParams + ) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>( + getObjectMapper().get().readValue( + RESOURCE_LIST_JSON_RESPONSE, + new TypeReference<List<Resource>>() {} + ), + HttpStatus.NOT_IMPLEMENTED + ); + } catch (IOException e) { + log.error( + "Couldn't serialize response for content type application/json", e + ); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourceActivationApi interface so no example is generated" + ); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation( + summary = "Updates partially a Resource", + operationId = "patchResource", + description = "This operation updates partially a Resource entity.", + tags = {"resource"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Updated"), + @ApiResponse(responseCode = "400", description = "Bad Request"), + @ApiResponse(responseCode = "401", description = "Unauthorized"), + @ApiResponse(responseCode = "403", description = "Forbidden"), + @ApiResponse(responseCode = "404", description = "Not Found"), + @ApiResponse(responseCode = "405", description = "Method Not allowed"), + @ApiResponse(responseCode = "409", description = "Conflict"), + @ApiResponse(responseCode = "500", description = "Internal Server Error") + }) + @RequestMapping( + value = "/resource/{id}", + produces = {"application/json;charset=utf-8"}, + consumes = {"application/json;charset=utf-8"}, + method = RequestMethod.PATCH + ) + default ResponseEntity<Resource> patchResource( + Principal principal, + @Parameter(description = "The Resource to be updated", required = true) + @Valid @RequestBody ResourceUpdate body, + @Parameter(description = "Identifier of the Resource", required = true) + @PathVariable("id") String id + ) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>( + getObjectMapper().get().readValue( + RESOURCE_JSON_RESPONSE, Resource.class + ), + HttpStatus.NOT_IMPLEMENTED + ); + } catch (IOException e) { + log.error( + "Couldn't serialize response for content type application/json", e + ); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourceActivationApi interface so no example is generated" + ); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation( + summary = "Retrieves a Resource by ID", + operationId = "retrieveResource", + description = "This operation retrieves a Resource entity. Attribute selection is enabled for all first-level attributes.", + tags = {"resource"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "400", description = "Bad Request"), + @ApiResponse(responseCode = "401", description = "Unauthorized"), + @ApiResponse(responseCode = "403", description = "Forbidden"), + @ApiResponse(responseCode = "404", description = "Not Found"), + @ApiResponse(responseCode = "405", description = "Method Not allowed"), + @ApiResponse(responseCode = "409", description = "Conflict"), + @ApiResponse(responseCode = "500", description = "Internal Server Error") + }) + @RequestMapping( + value = "/resource/{id}", + produces = {"application/json;charset=utf-8"}, + method = RequestMethod.GET + ) + default ResponseEntity<Resource> retrieveResource( + Principal principal, + @Parameter(description = "Identifier of the Resource", required = true) + @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") + @Valid @RequestParam(value = "fields", required = false) String fields + ) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>( + getObjectMapper().get().readValue( + RESOURCE_JSON_RESPONSE, Resource.class + ), + HttpStatus.NOT_IMPLEMENTED + ); + } catch (IOException e) { + log.error( + "Couldn't serialize response for content type application/json", e + ); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourceActivationApi interface so no example is generated" + ); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..30b703ed1f2389c3333360bf6951804c7d4205f7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java @@ -0,0 +1,214 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2024 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ + +package org.etsi.osl.tmf.ram702.api; + +import java.security.Principal; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import org.etsi.osl.model.nfv.UserRoleType; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +/** + * Controller class that implements the Resource Activation API. + * Handles HTTP requests for creating, retrieving, updating, and deleting resources. + */ +@Controller +@RequestMapping("/resourceActivationAndConfiguration/v4/") +public class ResourceActivationApiController implements ResourceActivationApi { + + private final ObjectMapper objectMapper; + private final HttpServletRequest request; + + @Autowired + private ResourceRepoService resourceRepoService; + + + /** + * Constructs a new ResourceActivationApiController with the specified ObjectMapper and HttpServletRequest. + * + * @param objectMapper the ObjectMapper for JSON processing + * @param request the HttpServletRequest for accessing request data + */ + @Autowired + public ResourceActivationApiController( + ObjectMapper objectMapper, + HttpServletRequest request + ) { + this.objectMapper = objectMapper; + this.request = request; + } + + + /** + * Creates a new resource. + * + * @param principal the security principal of the user making the request + * @param resource the resource to create + * @return a ResponseEntity containing the created resource and HTTP status + */ + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + @Override + public ResponseEntity<Resource> createResource( + Principal principal, + @Valid ResourceCreate resource + ) { + try { + if (SecurityContextHolder.getContext().getAuthentication() != null) { + resource.setRelatedParty( + AddUserAsOwnerToRelatedParties.addUser( + principal.getName(), + principal.getName(), + UserPartRoleType.REQUESTER, + "", + resource.getRelatedParty() + ) + ); + + Resource createdResource = resourceRepoService.addResource(resource); + return new ResponseEntity<>(createdResource, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.FORBIDDEN); + } + } catch (Exception e) { + log.error("Error creating resource", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); // 500 Internal Server Error for other exceptions + } + } + + + /** + * Deletes a resource by its identifier. + * + * @param id the identifier of the resource to delete + * @return a ResponseEntity with the appropriate HTTP status + */ + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + @Override + public ResponseEntity<Void> deleteResource(String id) { + try { + + return new ResponseEntity<Void>( resourceRepoService.deleteByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + /** + * Lists resources based on the provided parameters. + * + * @param principal the security principal of the user making the request + * @param fields the fields to include in the response + * @param offset the offset for pagination + * @param limit the maximum number of resources to return + * @param allParams additional parameters for filtering + * @return a ResponseEntity containing the list of resources and HTTP status + */ + @SuppressWarnings("unchecked") + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + @Override + public ResponseEntity<List<Resource>> listResource( + Principal principal, + @Valid String fields, + @Valid Integer offset, + @Valid Integer limit, + Map<String, String> allParams + ) { + try { + List<Resource> resources = resourceRepoService.findAll( + principal.getName(), UserPartRoleType.REQUESTER + ); + return new ResponseEntity<>(resources, HttpStatus.OK); + + } catch (Exception e) { + log.error("Error listing resources", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + /** + * Updates an existing resource by partially updating its fields. + * + * @param principal the security principal of the user making the request + * @param resource the resource data to update + * @param id the identifier of the resource to update + * @return a ResponseEntity containing the updated resource and HTTP status + */ + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + @Override + public ResponseEntity<Resource> patchResource( + Principal principal, + @Valid ResourceUpdate resource, + String id + ) { + Resource c = resourceRepoService.updateResource(id, resource, true); + + return new ResponseEntity< Resource >(c, HttpStatus.OK); + } + + + /** + * Retrieves a resource by its identifier. + * + * @param principal the security principal of the user making the request + * @param id the identifier of the resource to retrieve + * @param fields the fields to include in the response + * @return a ResponseEntity containing the resource and HTTP status + */ + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + @Override + public ResponseEntity<Resource> retrieveResource( + Principal principal, + String id, + @Valid String fields + ) { + try { + + return new ResponseEntity<Resource>( resourceRepoService.findByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<Resource>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } +} + diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..75c44d9ba434c8b9a9d47b60ab87378385df9692 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java @@ -0,0 +1,101 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2024 openslice.io + * %% + * 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. + * =========================LICENSE_END================================== + */ + +package org.etsi.osl.tmf.ram702.api; + +import java.io.IOException; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.camel.LoggingLevel; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Configuration +@Component +public class ResourceActivationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ResourceActivationApiRouteBuilder.class.getName()); + + @Value("${CATALOG_ADD_RESOURCEACTIVATION}") + private String CATALOG_ADD_RESOURCEACTIVATION = ""; + + @Value("${CATALOG_UPD_RESOURCEACTIVATION}") + private String CATALOG_UPD_RESOURCEACTIVATION = ""; + + @Value("${CATALOG_UPDADD_RESOURCEACTIVATION}") + private String CATALOG_UPDADD_RESOURCEACTIVATION = ""; + + @Value("${CATALOG_GET_RESOURCEACTIVATION_BY_ID}") + private String CATALOG_GET_RESOURCEACTIVATION_BY_ID = ""; + + @Autowired + private ProducerTemplate template; + + @Autowired + ResourceRepoService resourceRepoService; + + @Override + public void configure() throws Exception { + + from( CATALOG_ADD_RESOURCEACTIVATION ) + .log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCEACTIVATION + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ResourceCreate.class, true) + .bean( resourceRepoService, "addResource(${body})") + .marshal() + .json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPD_RESOURCEACTIVATION ) + .log(LoggingLevel.INFO, log, CATALOG_UPD_RESOURCEACTIVATION + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ResourceUpdate.class, true) + .bean( resourceRepoService, "updateResource(${header.resourceId}, ${body}, ${header.triggerServiceActionQueue} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPDADD_RESOURCEACTIVATION ) + .log(LoggingLevel.INFO, log, CATALOG_UPDADD_RESOURCEACTIVATION + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ResourceCreate.class, true) + .bean( resourceRepoService, "addOrUpdateResourceByNameCategoryVersion(${header.aname},${header.acategory}, ${header.aversion}, ${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + } + + static String toJsonString(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString(object); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceNotFoundException.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..1f08d3e6a5df8724d35f495f625d7605e61f1623 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceNotFoundException.java @@ -0,0 +1,8 @@ +package org.etsi.osl.tmf.ram702.api; + +public class ResourceNotFoundException extends ApiException { + + public ResourceNotFoundException(String message) { + super(404, message); // Setting the HTTP status code to 404 for "Not Found" + } +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiRouteBuilder.java index 59e04eaa6022e9d37affddd650e6be50dc08545f..79b2f433e1e712e13c9a5eea8f967de513ebea29 100644 --- a/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiRouteBuilder.java @@ -35,8 +35,8 @@ public class ResourceSpecificationApiRouteBuilder extends RouteBuilder { private String CATALOG_GET_RESOURCESPEC_BY_ID = ""; - @Value("${CATALOG_GET_RESOURCESPEC_BY_ÎAME_CATEGORY}") - private String CATALOG_GET_RESOURCESPEC_BY_ÎAME_CATEGORY = ""; + @Value("${CATALOG_GET_RESOURCESPEC_BY_NAME_CATEGORY}") + private String CATALOG_GET_RESOURCESPEC_BY_NAME_CATEGORY = ""; @Autowired private ProducerTemplate template; @@ -79,8 +79,8 @@ public class ResourceSpecificationApiRouteBuilder extends RouteBuilder { .marshal().json( JsonLibrary.Jackson) .convertBodyTo( String.class ); - from( CATALOG_GET_RESOURCESPEC_BY_ÎAME_CATEGORY ) - .log(LoggingLevel.INFO, log, CATALOG_GET_RESOURCESPEC_BY_ÎAME_CATEGORY + " message received!") + from( CATALOG_GET_RESOURCESPEC_BY_NAME_CATEGORY ) + .log(LoggingLevel.INFO, log, CATALOG_GET_RESOURCESPEC_BY_NAME_CATEGORY + " message received!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( resourceSpecificationRepoService, "findByNameAndCategoryAndVersionEager(${header.aname}, ${header.acategory}, ${header.aversion} )") .marshal().json( JsonLibrary.Jackson) diff --git a/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilder.java index fc6252fb05e6d79fbf958ccdbd8348d8fa1114b9..bc445f18d73265463f8a7e11f3eacc6f4e68a1d0 100644 --- a/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilder.java @@ -74,7 +74,7 @@ public class ResourceApiRouteBuilder extends RouteBuilder { public void configure() throws Exception { from( CATALOG_ADD_RESOURCE ) - .log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " message received!") + .log(LoggingLevel.DEBUG, log, CATALOG_ADD_RESOURCE + " message received!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceCreate.class, true) .bean( resourceRepoService, "addResource(${body})") @@ -83,13 +83,13 @@ public class ResourceApiRouteBuilder extends RouteBuilder { .convertBodyTo( String.class ); from( CATALOG_GET_RESOURCE_BY_ID ) - .log(LoggingLevel.INFO, log, CATALOG_GET_RESOURCE_BY_ID + " message received!") + .log(LoggingLevel.DEBUG, log, CATALOG_GET_RESOURCE_BY_ID + " message received!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( resourceRepoService, "getResourceEagerAsString") .convertBodyTo( String.class ); from( CATALOG_UPD_RESOURCE ) - .log(LoggingLevel.INFO, log, CATALOG_UPD_RESOURCE + " message received!") + .log(LoggingLevel.DEBUG, log, CATALOG_UPD_RESOURCE + " message received!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceUpdate.class, true) .bean( resourceRepoService, "updateResource(${header.resourceId}, ${body}, ${header.triggerServiceActionQueue} )") @@ -97,14 +97,14 @@ public class ResourceApiRouteBuilder extends RouteBuilder { .convertBodyTo( String.class ); from( CATALOG_RESOURCES_OF_PARTNERS ) - .log(LoggingLevel.INFO, log, CATALOG_RESOURCES_OF_PARTNERS + " message received!") + .log(LoggingLevel.DEBUG, log, CATALOG_RESOURCES_OF_PARTNERS + " message received!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( resourceRepoService, "findAllActiveAndReservedResourcesOfPartners") .marshal().json( JsonLibrary.Jackson) .convertBodyTo( String.class ); from( CATALOG_UPDADD_RESOURCE ) - .log(LoggingLevel.INFO, log, CATALOG_UPDADD_RESOURCE + " message received!") + .log(LoggingLevel.DEBUG, log, CATALOG_UPDADD_RESOURCE + " message received!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceCreate.class, true) .bean( resourceRepoService, "addOrUpdateResourceByNameCategoryVersion(${header.aname},${header.acategory}, ${header.aversion}, ${body})") diff --git a/src/main/java/org/etsi/osl/tmf/ri639/repo/ResourceRepository.java b/src/main/java/org/etsi/osl/tmf/ri639/repo/ResourceRepository.java index 86de40b616595331c3252e07f46fd6035fa73c08..446a04ca1c4193c892f0f27ece6d20126ac148cf 100644 --- a/src/main/java/org/etsi/osl/tmf/ri639/repo/ResourceRepository.java +++ b/src/main/java/org/etsi/osl/tmf/ri639/repo/ResourceRepository.java @@ -22,15 +22,14 @@ package org.etsi.osl.tmf.ri639.repo; import java.util.List; import java.util.Optional; import org.etsi.osl.tmf.ri639.model.Resource; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Repository; @Repository -public interface ResourceRepository extends CrudRepository<Resource, Long>, PagingAndSortingRepository<Resource, Long> { +public interface ResourceRepository extends JpaRepository<Resource, Long> { Optional<Resource> findByUuid(String id); diff --git a/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java b/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java index 9e79d472e5903d40fea50714d745f4762057ae2b..3f645f48f95c316178db7272a84d711b2392c89d 100644 --- a/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java @@ -60,12 +60,14 @@ import org.etsi.osl.tmf.ri639.model.ResourceStateChangeNotification; import org.etsi.osl.tmf.ri639.model.ResourceUpdate; import org.etsi.osl.tmf.ri639.repo.ResourceRepository; import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.transform.ResultTransformer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import jakarta.persistence.EntityManagerFactory; import jakarta.validation.Valid; @@ -91,6 +93,9 @@ public class ResourceRepoService { @Autowired ResourceApiRouteBuilderEvents resourceApiRouteBuilder; + + @Autowired + ServiceRepoService serviceRepoService; @Autowired public ResourceRepoService(EntityManagerFactory factory) { @@ -195,7 +200,7 @@ public class ResourceRepoService { return (List<Resource>) this.resourceRepo.findByRolename(name); } - + @Transactional public Resource addResource(@Valid ResourceCreate resource) { logger.info("Will add Resource: " + resource.getName()); @@ -268,7 +273,7 @@ public class ResourceRepoService { noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC)); s.addNoteItem(noteItem); - s = this.resourceRepo.save(s); + s = this.resourceRepo.saveAndFlush(s); raiseResourceCreateNotification(s); return s; @@ -444,7 +449,8 @@ public class ResourceRepoService { } - resource = this.resourceRepo.save(resource); + resource = this.resourceRepo.saveAndFlush(resource); + if (resourceCharacteristicChanged) { raiseResourceAttributeValueChangeEventNotification(resource); } else if (resourceStateChanged) { @@ -453,6 +459,7 @@ public class ResourceRepoService { return resource; } + @Transactional public String getResourceEagerAsString(String id) throws JsonProcessingException { Resource s = this.getResourceEager(id); ObjectMapper mapper = new ObjectMapper(); @@ -462,11 +469,13 @@ public class ResourceRepoService { return res; } + + @Transactional public Resource getResourceEager(String id) { - Session session = sessionFactory.openSession(); - Transaction tx = session.beginTransaction(); + Resource s = null; - try { + try(Session session = sessionFactory.openSession()) { + Transaction tx = session.beginTransaction(); s = (Resource) session.get(Resource.class, id); if (s == null) { return this.findByUuid(id);// last resort @@ -482,15 +491,15 @@ public class ResourceRepoService { tx.commit(); - } finally { - session.close(); + } catch (Exception e) { + e.printStackTrace(); } return s; } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseResourceCreateNotification(Resource so) { ResourceCreateNotification n = new ResourceCreateNotification(); ResourceCreateEvent event = new ResourceCreateEvent(); @@ -500,7 +509,7 @@ public class ResourceRepoService { } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseResourceAttributeValueChangeEventNotification(Resource so) { ResourceAttributeValueChangeNotification n = new ResourceAttributeValueChangeNotification(); ResourceAttributeValueChangeEvent event = new ResourceAttributeValueChangeEvent(); @@ -511,8 +520,8 @@ public class ResourceRepoService { } - - @Transactional + + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseResourceStateChangeEventNotification(Resource so) { ResourceStateChangeNotification n = new ResourceStateChangeNotification(); ResourceStateChangeEvent event = new ResourceStateChangeEvent(); @@ -549,6 +558,7 @@ public class ResourceRepoService { return result; } + @Transactional public Void deleteByUuid(String id) { Optional<Resource> optionalCat = this.resourceRepo.findByUuid(id); Resource s = optionalCat.get(); diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java index f2a517266d56a3334fbf812e3806a5a4ede9b5ed..eb6ca09c1cf0d752a8a84412b2b5b054b6e2b2a5 100644 --- a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java @@ -1450,7 +1450,12 @@ public class ServiceSpecificationRepoService { serviceSpecCharacteristicItem.setValidFor( sourceChar.getValidFor() ); for (ResourceSpecificationCharacteristicValue cv : sourceChar.getResourceSpecCharacteristicValue()) { ServiceSpecCharacteristicValue serviceSpecCharacteristicValueItem = new ServiceSpecCharacteristicValue(); - serviceSpecCharacteristicValueItem.setValue( new Any( cv.getValue().getValue(), cv.getValue().getAlias())); + if ( cv.getValue()!=null && cv.getValue().getValue()!=null) { + serviceSpecCharacteristicValueItem.setValue( new Any( cv.getValue().getValue(), cv.getValue().getAlias())); + } else { + serviceSpecCharacteristicValueItem.setValue( new Any( "", "")); + } + serviceSpecCharacteristicValueItem.isDefault( cv.isIsDefault() ); serviceSpecCharacteristicValueItem.setUnitOfMeasure( cv.getUnitOfMeasure() ); serviceSpecCharacteristicItem.addServiceSpecCharacteristicValueItem(serviceSpecCharacteristicValueItem ); diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java index 93afc976d554ffe86976320a3e0d56fd7b591191..9373f79108c8a9c7fc49ee7ec2904323c1074d19 100644 --- a/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java @@ -123,7 +123,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( CATALOG_ADD_SERVICE ) - .log(LoggingLevel.INFO, log, CATALOG_ADD_SERVICE + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_ADD_SERVICE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ServiceCreate.class, true) .bean( serviceRepoService, "addService(${body})") @@ -131,7 +131,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { .convertBodyTo( String.class ); from( CATALOG_GET_SERVICE_BY_ID ) - .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICE_BY_ID + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_GET_SERVICE_BY_ID + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( serviceRepoService, "getServiceEagerAsString") .convertBodyTo( String.class ); @@ -139,7 +139,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( CATALOG_UPD_SERVICE ) - .log(LoggingLevel.INFO, log, CATALOG_UPD_SERVICE + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_UPD_SERVICE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ServiceUpdate.class, true) .bean( serviceRepoService, "updateService(${header.serviceid}, ${body}, ${header.triggerServiceActionQueue} )") @@ -148,14 +148,14 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( CATALOG_SERVICE_QUEUE_ITEMS_GET ) - .log(LoggingLevel.INFO, log, CATALOG_SERVICE_QUEUE_ITEMS_GET + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_SERVICE_QUEUE_ITEMS_GET + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( serviceRepoService, "findAllServiceActionQueueItems") .marshal().json( JsonLibrary.Jackson) .convertBodyTo( String.class ); from( CATALOG_SERVICE_QUEUE_ITEM_UPD ) - .log(LoggingLevel.INFO, log, CATALOG_SERVICE_QUEUE_ITEM_UPD + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_SERVICE_QUEUE_ITEM_UPD + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ServiceActionQueueItem.class, true) .bean( serviceRepoService, "updateServiceActionQueueItem(${body})") @@ -163,7 +163,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { .convertBodyTo( String.class ); from( CATALOG_SERVICE_QUEUE_ITEM_DELETE ) - .log(LoggingLevel.INFO, log, CATALOG_SERVICE_QUEUE_ITEM_DELETE + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_SERVICE_QUEUE_ITEM_DELETE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ServiceActionQueueItem.class, true) .bean( serviceRepoService, "deleteServiceActionQueueItemByUuid(${header.itemid})"); @@ -171,7 +171,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( CATALOG_SERVICES_TO_TERMINATE ) - .log(LoggingLevel.INFO, log, CATALOG_SERVICES_TO_TERMINATE + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_SERVICES_TO_TERMINATE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( serviceRepoService, "findAllActiveServicesToTerminate") .marshal().json( JsonLibrary.Jackson) @@ -179,7 +179,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( CATALOG_SERVICES_OF_PARTNERS ) - .log(LoggingLevel.INFO, log, CATALOG_SERVICES_OF_PARTNERS + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_SERVICES_OF_PARTNERS + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( serviceRepoService, "findAllActiveAndReservedServicesOfPartners") .marshal().json( JsonLibrary.Jackson) @@ -187,14 +187,14 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( CATALOG_GET_SERVICE_BY_ORDERID ) - .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICE_BY_ORDERID + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, CATALOG_GET_SERVICE_BY_ORDERID + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .bean( serviceRepoService, "getServicesFromOrderID") .marshal().json( JsonLibrary.Jackson) .convertBodyTo( String.class ); from( NFV_CATALOG_NS_LCMCHANGED ) - .log(LoggingLevel.INFO, log, NFV_CATALOG_NS_LCMCHANGED + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, NFV_CATALOG_NS_LCMCHANGED + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, DeploymentDescriptor.class, true) .bean( serviceRepoService, "nfvCatalogNSResourceChanged(${body})"); @@ -202,7 +202,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( EVENT_RESOURCE_STATE_CHANGED ) - .log(LoggingLevel.INFO, log, EVENT_RESOURCE_STATE_CHANGED + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, EVENT_RESOURCE_STATE_CHANGED + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceStateChangeNotification.class, true) .bean( serviceRepoService, "resourceStateChangedEvent(${body})"); @@ -216,7 +216,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { .logHandled(true) .retriesExhaustedLogLevel(LoggingLevel.ERROR) .retryAttemptedLogLevel(LoggingLevel.ERROR)) - .log(LoggingLevel.INFO, log, EVENT_RESOURCE_CREATE + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, EVENT_RESOURCE_CREATE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceCreateNotification.class, true) .bean( serviceRepoService, "resourceCreatedEvent(${body})"); @@ -233,7 +233,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder { .retriesExhaustedLogLevel(LoggingLevel.ERROR) .retryAttemptedLogLevel(LoggingLevel.ERROR)) - .log(LoggingLevel.INFO, log, EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED + " message received and will be processed for service inventory!") + .log(LoggingLevel.DEBUG, log, EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceAttributeValueChangeNotification.class, true) .bean( serviceRepoService, "resourceAttrChangedEvent(${body})"); diff --git a/src/main/java/org/etsi/osl/tmf/sim638/repo/ServiceRepository.java b/src/main/java/org/etsi/osl/tmf/sim638/repo/ServiceRepository.java index bd2cbf0c15ceb24a1fd8d65d20734ebe4a3a8638..8c920375ad11b35fcd9eb5ad794f3e029ad6f839 100644 --- a/src/main/java/org/etsi/osl/tmf/sim638/repo/ServiceRepository.java +++ b/src/main/java/org/etsi/osl/tmf/sim638/repo/ServiceRepository.java @@ -22,15 +22,14 @@ package org.etsi.osl.tmf.sim638.repo; import java.util.List; import java.util.Optional; import org.etsi.osl.tmf.sim638.model.Service; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Repository; @Repository -public interface ServiceRepository extends CrudRepository<Service, Long>, PagingAndSortingRepository<Service, Long> { +public interface ServiceRepository extends JpaRepository<Service, Long> { Optional<Service> findByUuid(String id); diff --git a/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java b/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java index eaf0609a083947ceee28114efacb3f886ee9b9f2..d4f9afa97279228592be78c5a81739dfa207ef85 100644 --- a/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java @@ -24,14 +24,19 @@ import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -73,6 +78,7 @@ import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.transform.ResultTransformer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.etsi.osl.model.nfv.DeploymentDescriptor; import org.etsi.osl.model.nfv.DeploymentDescriptorVxFInstanceInfo; @@ -281,6 +287,7 @@ public class ServiceRepoService { } + @Transactional public Service addService(@Valid ServiceCreate service) { logger.info("Will add service: " + service.getName() ); Service s = new Service(); @@ -330,11 +337,11 @@ public class ServiceRepoService { Note noteItem = new Note(); noteItem.setText("Service " + s.getState() ); - noteItem.setAuthor("API"); + noteItem.setAuthor("SIM-638"); noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); s.addNoteItem(noteItem); - s = this.serviceRepo.save( s ); + s = this.serviceRepo.saveAndFlush( s ); raiseServiceCreateNotification(s); return s; @@ -348,6 +355,7 @@ public class ServiceRepoService { .orElse(null); } + /** * @param id * @param servUpd @@ -358,17 +366,15 @@ public class ServiceRepoService { */ @Transactional public Service updateService(String id, @Valid ServiceUpdate servUpd, boolean triggerServiceActionQueue, Service updatedFromParentService, Service updatedFromChildService ) { - //Service service = this.findByUuid(id); - Service service = this.getServiceEager(id); + Service service = this.getServiceEager(id); if ( service == null ) { logger.error("Service cannot be found in registry, UUID: " + id ); return null; } - + logger.info("Will update service: " + service.getName() ); - //logger.info("Will update service details: " + s.toString() ); ObjectMapper mapper = new ObjectMapper(); String originaServiceAsJson = null; @@ -427,8 +433,12 @@ public class ServiceRepoService { boolean stateChanged = false; ServiceStateType previousState = service.getState(); if (servUpd.getState() != null ) { + logger.debug("=============SERVICE STATE == previousState => " + service.getState() +", " + servUpd.getName()); + logger.debug("=============SERVICE STATE == newState ======> " + servUpd.getState() +", " + service.getName()); + stateChanged = service.getState() != servUpd.getState(); service.setState(servUpd.getState()); + } if (servUpd.getServiceSpecificationRef() != null ) { @@ -469,10 +479,6 @@ public class ServiceRepoService { boolean serviceCharacteristicChangedContainsNSLCM; String charChangedForNotes = ""; - //List<Characteristic> childCharacteristicsChanged = new ArrayList<>(); - - - //logger.info("==> Will update serviceToString: " + service.toString() ); if ( servUpd.getServiceCharacteristic()!=null ) { @@ -520,6 +526,7 @@ public class ServiceRepoService { } else { service.addServiceCharacteristicItem(n); + if ( !n.getName().contains("::") ) { //it is not a child characteristic serviceCharacteristicChanged = true; charChangedForNotes += n.getName() + ", "; @@ -564,69 +571,97 @@ public class ServiceRepoService { if (stateChanged) { Note noteItem = new Note(); noteItem.setText("Service is " + service.getState() ); - noteItem.setAuthor("API"); + noteItem.setAuthor("SIM-638"); noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); service.addNoteItem(noteItem); } + /** + * Check here if the characteristics changed are of interest for LCM rules and further processing by the orchestrator + */ + Characteristic lcmchar = service.getServiceCharacteristicByName("_LCM_CHARACTERISTICS_"); + if ( lcmchar != null && lcmchar.getValue() != null && !lcmchar.getValue().getValue().equals("all") && !charChangedForNotes.equals("")) { + + // Split the strings into arrays of values + String[] arrayA = lcmchar.getValue().getValue().split(","); + String[] arrayB = charChangedForNotes.split(","); + // Convert strb values into a set for faster lookup + // Check if any value from stra exists in strb + boolean valueExists = false; + for (String value : arrayA) { + for (String b : arrayB) { + if ( b.equals(value) ) { + valueExists = true; // A common value exists + break; + } + } + } + if (!valueExists) { + serviceCharacteristicChanged=false; + } + } if (charChangedForNotes.contains( "reconciledAt") ) { //this is just a sync message, so we need to igore such changes serviceCharacteristicChanged = false; + logger.debug("=============================================> Just reconciledAt changed" ); } if (serviceCharacteristicChanged) { - Note noteItem = new Note(); - noteItem.setText("Service Characteristic changed: " + charChangedForNotes ); - noteItem.setAuthor("API"); - noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); - service.addNoteItem(noteItem); + + Characteristic noteCheck = service.getServiceCharacteristicByName("_DETAILED_NOTES_"); + if ( noteCheck!= null + && noteCheck.getValue() != null + && noteCheck.getValue().getValue() != null + && !noteCheck.getValue().getValue().equals("")) { + Note noteItem = new Note(); + noteItem.setText("Service Characteristic changed: " + charChangedForNotes ); + noteItem.setAuthor("SIM638-API"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + service.addNoteItem(noteItem); + + } } + - - - service = this.serviceRepo.save( service ); + service = this.serviceRepo.saveAndFlush( service ); + + String requestedServiceAsJson = null; + try { + requestedServiceAsJson = mapper.writeValueAsString( service ); + } catch (JsonProcessingException e) { + logger.error("cannot umarshall service: " + service.getName() ); + e.printStackTrace(); + } /** * Save in ServiceActionQueueItem */ - if (triggerServiceActionQueue && stateChanged) { - ServiceActionQueueItem saqi = new ServiceActionQueueItem(); - saqi.setServiceRefId( id ); - saqi.setOriginalServiceInJSON( originaServiceAsJson ); - if (stateChanged) { - if ( service.getState().equals( ServiceStateType.INACTIVE) ) { - saqi.setAction( ServiceActionQueueAction.DEACTIVATE ); - }else if ( service.getState().equals( ServiceStateType.TERMINATED) ) { - saqi.setAction( ServiceActionQueueAction.TERMINATE ); - } - - } - - if ( saqi.getAction() != ServiceActionQueueAction.NONE ) { - this.addServiceActionQueueItem(saqi); - } - } - - -// //here on any state change of a Service we must send an ActionQueueItem that reflects the state changed with the Action - if ( stateChanged ) { - ServiceActionQueueItem saqi = new ServiceActionQueueItem(); - saqi.setServiceRefId( id ); - saqi.setOriginalServiceInJSON( originaServiceAsJson ); - if ( service.getState().equals( ServiceStateType.ACTIVE) ) { - saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOACTIVE ); - this.addServiceActionQueueItem(saqi); - }else if ( previousState!=null && previousState.equals( ServiceStateType.ACTIVE) ) { - saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ); - this.addServiceActionQueueItem(saqi); - } - } - - if ( serviceCharacteristicChanged && service.getState().equals( ServiceStateType.ACTIVE) && previousState!=null && previousState.equals( ServiceStateType.ACTIVE) && triggerServiceActionQueue ) { + Boolean childServiceCharacteristicChanged = false; + + if ( stateChanged ) { + ServiceActionQueueItem saqi = new ServiceActionQueueItem(); + saqi.setServiceRefId( id ); + saqi.setOriginalServiceInJSON( originaServiceAsJson ); + + if ( service.getState().equals( ServiceStateType.INACTIVE) ) { + saqi.setAction( ServiceActionQueueAction.DEACTIVATE ); + }else if ( service.getState().equals( ServiceStateType.TERMINATED) ) { + saqi.setAction( ServiceActionQueueAction.TERMINATE ); + }else if ( service.getState().equals( ServiceStateType.ACTIVE) ) { + saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOACTIVE ); + }else if ( previousState!=null && previousState.equals( ServiceStateType.ACTIVE) ) { + saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ); + } + + if ( saqi.getAction() != ServiceActionQueueAction.NONE ) { + logger.debug("==========addServiceActionQueueItem==============> saqi.getAction() = " + saqi.getAction() ); + this.addServiceActionQueueItem(service, saqi); + } + } else if ( serviceCharacteristicChanged && service.getState().equals( ServiceStateType.ACTIVE) && previousState!=null && previousState.equals( ServiceStateType.ACTIVE) && triggerServiceActionQueue ) { ServiceActionQueueItem saqi = new ServiceActionQueueItem(); saqi.setServiceRefId( id ); saqi.setOriginalServiceInJSON( originaServiceAsJson ); @@ -634,33 +669,24 @@ public class ServiceRepoService { if ( serviceCharacteristicChangedContainsPrimitive ) { saqi.setAction( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED_MANODAY2 ); } - this.addServiceActionQueueItem(saqi); + logger.debug("==========addServiceActionQueueItem==============> serviceCharacteristicChanged && service.getState().eq charChangedForNotes= " + charChangedForNotes); + this.addServiceActionQueueItem(service, saqi); + childServiceCharacteristicChanged = true; } + + + + + /* * Update any parent service */ for (ServiceRelationship serviceRelationship : service.getServiceRelationship()) { - if (serviceRelationship.getRelationshipType().equals("ChildService")) { + if (serviceRelationship.getRelationshipType().equals("ChildService") ) { if (serviceRelationship.getService() != null) { - - - if (serviceCharacteristicChanged) { - if (updatedFromParentService == null || (updatedFromParentService != null && !updatedFromParentService.getId().equals(serviceRelationship.getService().getId()))) { // avoid circular - ServiceActionQueueItem saqi = new ServiceActionQueueItem(); // this will trigger lcm rule to parent - saqi.setServiceRefId(serviceRelationship.getService().getId()); - try { - saqi.setOriginalServiceInJSON( mapper.writeValueAsString( service ) ); //pass the child service as is - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - saqi.setAction(ServiceActionQueueAction.EVALUATE_CHILD_CHARACTERISTIC_CHANGED); - this.addServiceActionQueueItem(saqi); - } - - } - if (stateChanged) { + if (stateChanged || childServiceCharacteristicChanged) { if (updatedFromParentService == null || (updatedFromParentService != null && !updatedFromParentService.getId().equals(serviceRelationship.getService().getId()))) { // avoid circular ServiceActionQueueItem saqi = new ServiceActionQueueItem(); // this will trigger lcm rule to parent saqi.setServiceRefId(serviceRelationship.getService().getId()); @@ -669,13 +695,16 @@ public class ServiceRepoService { } catch (JsonProcessingException e) { e.printStackTrace(); } - saqi.setAction(ServiceActionQueueAction.EVALUATE_CHILD_STATE_CHANGE ); - this.addServiceActionQueueItem(saqi); + if (stateChanged) { + saqi.setAction(ServiceActionQueueAction.EVALUATE_CHILD_STATE_CHANGE ); + logger.debug("==========addServiceActionQueueItem==============> EVALUATE_CHILD_STATE_CHANGE " + charChangedForNotes); + } else if ( childServiceCharacteristicChanged) { + saqi.setAction(ServiceActionQueueAction.EVALUATE_CHILD_CHARACTERISTIC_CHANGED); + logger.debug("==========addServiceActionQueueItem==============> EVALUATE_CHILD_CHARACTERISTIC_CHANGED " + charChangedForNotes); + } + this.addServiceActionQueueItem(service, saqi); } } - - - } } } @@ -729,23 +758,6 @@ public class ServiceRepoService { } - Characteristic schart = service.getServiceCharacteristicByName("long_string"); - - if ( schart!= null ) { - String teest = schart.getValue().getValue(); - logger.info("schart size = " + teest.length() ); - - logger.info("schart " + teest ); - System.out.println("The value is : \n " + teest); -// try (PrintWriter out = new PrintWriter("C:\\tranoris\\ctranup\\personal\\Invoices\\filename.txt")) { -// out.println( teest ); -// } catch (FileNotFoundException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } - logger.info("======================================================================================================"); - } - return service; } @@ -760,43 +772,72 @@ public class ServiceRepoService { ObjectMapper primitivesObjectMapper = new ObjectMapper(); // Retrieve the service characteristic based on the name - Characteristic aNSLCMCharacteristic = service.getServiceCharacteristicByName(n.getName()); - - // Retrieve the current value as a string directly from the service characteristic - String aNSLCMCharacteristicValue = service.getServiceCharacteristicByName(n.getName()).getValue().getValue(); - - // Check if the current service characteristic value is null or explicitly "null" and initialize if needed - if (aNSLCMCharacteristicValue == null || "null".equals(aNSLCMCharacteristicValue) || aNSLCMCharacteristicValue.equals("")) { - service.getServiceCharacteristicByName(n.getName()).getValue().setValue("[]"); - } + Characteristic aNSLCMStatusesCharacteristic = service.getServiceCharacteristicByName(n.getName()); + + // Retrieve the current NSLCM statuses, and extract the new status + // to be appended + String aNSLCMStatusesBeforeUpdate = service + .getServiceCharacteristicByName(n.getName()).getValue().getValue(); + String aNSLCMNewStatus = n.getValue().getValue(); + + // Check if the current NSLCM statuses value is null or explicitly "null" + // and, if thats the case start an empty JSON array (this takes place when initializing the characteristic) + if ( aNSLCMStatusesBeforeUpdate == null || + aNSLCMStatusesBeforeUpdate.isEmpty() || + aNSLCMStatusesBeforeUpdate.equals("null") + ){ + try { + service.getServiceCharacteristicByName(n.getName()).getValue().setValue( + primitivesObjectMapper.writeValueAsString(primitivesObjectMapper.createArrayNode()) + ); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } // Check if the current characteristic value is not null and not explicitly "null" - if (n.getValue().getValue() != null || !"null".equals(n.getValue().getValue())) { - aNSLCMCharacteristicValue = service.getServiceCharacteristicByName(n.getName()).getValue().getValue(); + if ( aNSLCMNewStatus != null && + !aNSLCMNewStatus.isEmpty() && + !aNSLCMNewStatus.equals("null") + ) { + try { + // Deserialize the current statuses back to an array list + ArrayNode nslcmStatusesJsonArray = (ArrayNode) primitivesObjectMapper.readTree( + service.getServiceCharacteristicByName(n.getName()).getValue().getValue() + ); - ArrayList<String> arrayList = null; + // Map the current status to json + JsonNode currenNSLCMStatus = primitivesObjectMapper.readTree(n.getValue().getValue()); - // Deserialize the current value back to an array list - try { - arrayList = primitivesObjectMapper.readValue(aNSLCMCharacteristicValue, new TypeReference<ArrayList<String>>() {}); + // Add the new status to the list if it's not already present and is not null + if (!containsNode(nslcmStatusesJsonArray, currenNSLCMStatus)) { + nslcmStatusesJsonArray.add(currenNSLCMStatus); + } + + // Finally, map the statuses list to a Json encoded one + aNSLCMStatusesCharacteristic.setValue( + new Any(primitivesObjectMapper.writeValueAsString(nslcmStatusesJsonArray), n.getValue().getAlias()) + ); } catch (JsonProcessingException e) { e.printStackTrace(); } + } + return service; + } - // Add the new value to the list if it's not already present and is not null - if (!arrayList.contains(n.getValue().getValue()) && n.getValue().getValue() != null) { - arrayList.add(n.getValue().getValue()); - } - - // Update the characteristic with the newly modified list - try { - aNSLCMCharacteristic.setValue(new Any(primitivesObjectMapper.writeValueAsString(arrayList), n.getValue().getAlias())); - } catch (JsonProcessingException e) { - e.printStackTrace(); + /** + * Helper method to check if an ArrayNode contains a specific JsonNode. + * This method uses Jackson's `equals()` for deep equality. + * @param arrayNode Array of Json Nodes + * @param jsonNode the object encoded as Jsons + */ + private static boolean containsNode(ArrayNode arrayNode, JsonNode jsonNode) { + for (JsonNode node : arrayNode) { + if (node.equals(jsonNode)) { + return true; } } - - return service; + return false; } @@ -824,30 +865,19 @@ public class ServiceRepoService { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Hibernate5JakartaModule()); String res = mapper.writeValueAsString(s); - - - Characteristic schart = s.getServiceCharacteristicByName("long_string"); - - if ( schart!= null ) { - String teest = schart.getValue().getValue(); - logger.info("schart size = " + teest.length() ); - - logger.info("schart " + teest ); - logger.info("======================================================================================================"); - } return res; } - @Transactional + + @Transactional public Service getServiceEager(String id) { if ( id == null || id.equals("")) { return null; } - Session session = sessionFactory.openSession(); - Transaction tx = session.beginTransaction(); Service s = null; - try { + try (Session session = sessionFactory.openSession()) { + Transaction tx = session.beginTransaction(); s = (Service) session.get(Service.class, id); if (s == null) { return this.findByUuid(id);// last resort @@ -864,15 +894,16 @@ public class ServiceRepoService { Hibernate.initialize(s.getPlace() ); tx.commit(); - } finally { - session.close(); - } + } catch (Exception e) { + e.printStackTrace(); + } + return s; } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseServiceCreateNotification(Service so) { ServiceCreateNotification n = new ServiceCreateNotification(); ServiceCreateEvent event = new ServiceCreateEvent(); @@ -882,7 +913,7 @@ public class ServiceRepoService { } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseServiceStateChangedNotification(Service so) { ServiceStateChangeNotification n = new ServiceStateChangeNotification(); ServiceStateChangeEvent event = new ServiceStateChangeEvent(); @@ -892,7 +923,7 @@ public class ServiceRepoService { } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseServiceAttributeValueChangedNotification(Service so) { ServiceAttributeValueChangeNotification n = new ServiceAttributeValueChangeNotification(); ServiceAttributeValueChangeEvent event = new ServiceAttributeValueChangeEvent(); @@ -912,15 +943,23 @@ public class ServiceRepoService { return (List<ServiceActionQueueItem>) this.serviceActionQueueRepo.findFirst10ByOrderByInsertedDate(); } - public ServiceActionQueueItem addServiceActionQueueItem(@Valid ServiceActionQueueItem item) { + public ServiceActionQueueItem addServiceActionQueueItem(Service service, @Valid ServiceActionQueueItem item) { logger.debug("Will add ServiceActionQueueItem ServiceRefId: " + item.getServiceRefId() ); - //find any similar action inqueue and delete them, so to keep this one as the most recent - List<ServiceActionQueueItem> result = this.serviceActionQueueRepo.findByServiceRefIdAndAction(item.getServiceRefId(), item.getAction()); - logger.debug("Will add ServiceActionQueueItem ServiceRefId result: " +result.size() ); - this.serviceActionQueueRepo.deleteByServiceRefIdAndAction(item.getServiceRefId(), item.getAction()); - - return this.serviceActionQueueRepo.save( item); + Characteristic lcmchar = service.getServiceCharacteristicByName("_LCM_CHARACTERISTICS_"); + if ( lcmchar == null || lcmchar.getValue() == null) { + //find any similar action inqueue and delete them, so to keep this one as the most recent + List<ServiceActionQueueItem> result = this.serviceActionQueueRepo.findByServiceRefIdAndAction(item.getServiceRefId(), item.getAction()); + logger.debug("Will add ServiceActionQueueItem ServiceRefId result: " +result.size() ); + if (result.size()>0) { //essentially it will not delete any requests, but just return with not adding the new action since it is already exists + return item; + } + this.serviceActionQueueRepo.deleteByServiceRefIdAndAction(item.getServiceRefId(), item.getAction()); + + } + + return this.serviceActionQueueRepo.save( item); + } /** @@ -1080,42 +1119,105 @@ public class ServiceRepoService { @Transactional - public void resourceAttrChangedEvent(@Valid ResourceAttributeValueChangeNotification resNotif) { + public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { - logger.debug("ResourceAttributeValueChangeNotification"); - Resource res = resNotif.getEvent().getEvent().getResource(); - logger.info("Will update services related to this resource with id = " + res.getId() ); + if (res.getResourceStatus()==null){ + logger.debug("================> updateServicesHavingThisSupportingResource resource status NULL"); + return; + } + logger.debug("================> Will update services related to this resource with id = " + res.getId() ); var aservices = findServicesHavingThisSupportingResourceID( res.getId() ); + logger.debug("================> Services found = " + aservices.size() ); for (Service as : aservices) { - Service aService = findByUuid(as.getId()); - - //if ( aService.getState().equals( ServiceStateType.ACTIVE ) ) { + Service aService = getServiceEager(as.getId()); + + ServiceStateType nextState = aService.getState(); + List<Resource> rlist = new ArrayList<Resource>(); + rlist.add(res); + + for (ResourceRef rref : aService.getSupportingResource()) { + if (!rref.getId().equals( res.getId())) { + Optional<Resource> result = resourceRepo.findByUuid(rref.getId()); + if (result.isPresent()) { + rlist.add( result.get() ); + if ( result.get().getResourceStatus()==null){ + logger.debug("================> updateServicesHavingThisSupportingResource resource status NULL for resource: "+ result.get().getName() ); + return; + } + } + } + } + + //copy characteristics, from resource to service + + /* + * Construct characteristic name + */ + + + + + + Boolean stateChaged = false; + ServiceUpdate supd = new ServiceUpdate(); + nextState = aService.findNextStateBasedOnResourceList(rlist); + supd.setState(nextState); + String stateText=""; + if ( !aService.getState().equals(nextState)) { + stateChaged = true; + stateText = "State changed from " + aService.getState() + " to " + nextState + "."; + logger.debug("====================> stateText = " + stateText); + } + for (Resource r : rlist) { + logger.debug("==================> state: ="+ r.getResourceStatus().name() + ", "+ r.getName() ); - - ServiceUpdate supd = new ServiceUpdate(); + } + + //adding all characteristics from service + for (Characteristic ch : aService.getServiceCharacteristic()) { + supd.addServiceCharacteristicItem(ch); - //copy characteristics from resource to service - for (org.etsi.osl.tmf.ri639.model.Characteristic rChar : res.getResourceCharacteristic()) { - Characteristic cNew = new Characteristic(); - cNew.setName( rChar.getName()); - cNew.value( new Any( rChar.getValue() )); - supd.addServiceCharacteristicItem( cNew ); + } + + + CharCopyResult result = new CharCopyResult(supd, false); + + if ( nextState == ServiceStateType.ACTIVE) { + if ( !aService.getState().equals(nextState) && nextState == ServiceStateType.ACTIVE) { + result = copyCharacteristicsFromAllResources(aService, supd, rlist); + } else { + result = copyCharacteristicsFromResource(aService, supd, res); } + } + + + + + + + if ( stateChaged || result.characteristicFoundDifferent) { + Characteristic noteCheck = as.getServiceCharacteristicByName("_DETAILED_NOTES_"); + if ( noteCheck!= null + && noteCheck.getValue() != null + && noteCheck.getValue().getValue() != null + && !noteCheck.getValue().getValue().equals("")) { + Note n = new Note(); + n.setText(stateText + "Supporting Resource changed with id: " + res.getId()); + n.setAuthor( "SIM638-API" ); + n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); + result.supd.addNoteItem( n ); + } - Note n = new Note(); - n.setText("Supporting Resource Attribute Changed with id: " + res.getId()); - n.setAuthor( "SIM638-API" ); - n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); - supd.addNoteItem( n ); + this.updateService( aService.getId(), result.supd , true, null, null); //update the service - this.updateService( aService.getId(), supd , true, null, null); //update the service - //} + } + } @@ -1125,7 +1227,96 @@ public class ServiceRepoService { } + private record CharCopyResult(ServiceUpdate supd, Boolean characteristicFoundDifferent) { + + } + + private CharCopyResult copyCharacteristicsFromAllResources(Service aService, ServiceUpdate supd, List<Resource> rlist) { + Boolean characteristicFoundDifferent = false; + CharCopyResult copyresult = new CharCopyResult(supd, characteristicFoundDifferent); + for (Resource r : rlist) { + copyresult = copyCharacteristicsFromResource(aService, copyresult.supd, r); + characteristicFoundDifferent = characteristicFoundDifferent || copyresult.characteristicFoundDifferent; + } + + CharCopyResult result = new CharCopyResult(copyresult.supd, copyresult.characteristicFoundDifferent); + return result ; + } + + private CharCopyResult copyCharacteristicsFromResource( @Valid Service aService, @Valid ServiceUpdate supd, @Valid Resource res) { + + Boolean characteristicFoundDifferent = false; + String kind = ""; + String resourcename = res.getName() ; + + org.etsi.osl.tmf.ri639.model.Characteristic ckind = res.getResourceCharacteristicByName("Kind"); + if ( ckind != null && ckind.getValue() != null) { + kind = ckind.getValue().getValue() ; //example "ConfigMap" + } + + if ( res.getName().indexOf('@')>0) { + String firstToken = res.getName().substring( 0, res.getName().indexOf('@') ); + resourcename = firstToken ; //example "cr0fc1234-amf" + } + + Boolean resourceIsSameKind = aService.checkIsKindResource(res) || aService.getServiceCharacteristicByName("Kind")==null; //either Kind is the same or simply does not exist. Then behave the same + if (resourceIsSameKind) { //if this service is the same kind as the resource then don't prefix the characteristic + kind = ""; + resourcename=""; + //rlist.add(res); //add only this one + }else { + //enable the following to remove crXXXXXX prefix in name +// org.etsi.osl.tmf.ri639.model.Characteristic kubinstance = res.getResourceCharacteristicByName("app.kubernetes.io/instance"); +// if ( kubinstance != null && kubinstance.getValue() != null) { +// String removePrefix = kubinstance.getValue().getValue(); +// resourcename = resourcename.replace( removePrefix + "-", ""); +// resourcename = resourcename.replace( removePrefix, ""); +// } + kind = kind + "."; + resourcename = resourcename + "."; + } + + String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; + String[] arrayDontCopyChars = dontCopyChars.split(","); + Set<String> setB = new HashSet<>(Arrays.asList(arrayDontCopyChars)); + for (org.etsi.osl.tmf.ri639.model.Characteristic rChar : res.getResourceCharacteristic()) { + if ( resourceIsSameKind || ( !setB.contains( rChar.getName()) && !rChar.getName().startsWith("org.etsi.osl") ) ){ //don;t copy characteristics in set + if ( rChar.getValue() != null ) { + + String characteristicname = kind + resourcename + rChar.getName(); + Characteristic servChar = supd.getServiceCharacteristicByName( characteristicname ); + if ( servChar != null && servChar.getValue() != null) { + if (! servChar.getValue().getValue().equals( rChar.getValue().getValue() ) ) { + characteristicFoundDifferent = true; + supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() )); + logger.debug("====================> update characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue()); + } + + } else { + Characteristic cNew = new Characteristic(); + cNew.setName( characteristicname ); + cNew.value( new Any( rChar.getValue() )); + supd.addServiceCharacteristicItem( cNew ); + characteristicFoundDifferent = true; + logger.debug("====================> add New characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue()); + } + + + } + } + + }; + + + CharCopyResult result = new CharCopyResult(supd, characteristicFoundDifferent); + return result ; + + + } + + + @Transactional public void resourceCreatedEvent(@Valid ResourceCreateNotification resNotif) { try { @@ -1150,53 +1341,38 @@ public class ServiceRepoService { }catch (Exception e) { e.printStackTrace(); } + } + @Transactional + public void resourceAttrChangedEvent(@Valid ResourceAttributeValueChangeNotification resNotif) { + try { + Resource res = resNotif.getEvent().getEvent().getResource(); + logger.debug("resourceAttrChangedEvent for: " + res.getName()); + updateServiceFromresourceChange(res); + }catch (Exception e) { + e.printStackTrace(); + } + } @Transactional private void updateServiceFromresourceChange(Resource res) { - - logger.info("Will update services related to this resource with id = " + res.getId() ); - var aservices = findServicesHavingThisSupportingResourceID(res.getId()); - - for (Service as : aservices) { - - Service aService = findByUuid(as.getId()); - - - List<Resource> rlist = new ArrayList<Resource>(); - for (ResourceRef rref : aService.getSupportingResource()) { - Optional<Resource> result = resourceRepo.findByUuid(rref.getId()); - if (result.isPresent()) { - rlist.add( result.get() ); - } - } - - rlist.add(res); //add also this one - - ServiceStateType nextState = aService.findNextStateBasedOnSupportingResources(rlist); - - ServiceUpdate supd = new ServiceUpdate(); - supd.setState(nextState); - Note n = new Note(); - n.setText("Supporting Resource " + res.getId() + " State Changed with status: " - + res.getResourceStatus() + ".Next state is " + nextState); - n.setAuthor("SIM638-API"); - n.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); - supd.addNoteItem(n); - - this.updateService(aService.getId(), supd, true, null, null); // update the service - } - - - updateResourceFromKubernetesLabel(res); - - + + addAnyNewRelatedResourcesFromKubernetesLabel(res); + updateServicesHavingThisSupportingResource(res); + } + /** + * This function will try to identify if the resource contains + * a characteristic called "org.etsi.osl.serviceId" and will check if there is a related service. + * If it is not it's add the resource back to the service. This is useful in kubernetes deployments, + * in cases of new resources in a namespace that are related to this service + * @param res + */ @Transactional - private void updateResourceFromKubernetesLabel(Resource res) { - logger.debug("updateResourceFromKubernetesLabel for: " + res.getName()); + private void addAnyNewRelatedResourcesFromKubernetesLabel(Resource res) { + logger.debug("updateResourceFromKubernetesLabel for: " + res.getName() + ", version" + res.getResourceVersion()); if (res.getResourceCharacteristicByName("org.etsi.osl.serviceId") != null) { @@ -1205,7 +1381,7 @@ public class ServiceRepoService { String serviceId = res.getResourceCharacteristicByName("org.etsi.osl.serviceId").getValue().getValue(); logger.debug("rserviceId: " + serviceId); - Service aService = findByUuid( serviceId ); + Service aService = getServiceEager( serviceId ); if ( aService !=null ) { logger.debug("aService found "); Boolean resourceFoundInSupportedResourcesOfService = false; @@ -1224,14 +1400,7 @@ public class ServiceRepoService { rref.id(res.getId()).name(res.getName()); supd.addSupportingResourceItem(rref ); - //copy characteristics from resource to service - for (org.etsi.osl.tmf.ri639.model.Characteristic rChar : res.getResourceCharacteristic()) { - Characteristic cNew = new Characteristic(); - cNew.setName( rChar.getName()); - cNew.value( new Any( rChar.getValue() )); - supd.addServiceCharacteristicItem( cNew ); - } - + Note n = new Note(); n.setText("Supporting Resource "+ res.getId() + " Added in service" ); @@ -1248,7 +1417,5 @@ public class ServiceRepoService { } - - } diff --git a/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiController.java b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiController.java index 60b5182926540c7de0c3101d617ce2f6c23e3a33..a83e78cb2ae5f9c06e69da4af97725636814bfcf 100644 --- a/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiController.java +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiController.java @@ -152,7 +152,7 @@ public class ServiceOrderApiController implements ServiceOrderApi { } } - @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) @Override public ResponseEntity<Void> deleteServiceOrder( Principal principal, diff --git a/src/main/java/org/etsi/osl/tmf/so641/repo/ServiceOrderRepository.java b/src/main/java/org/etsi/osl/tmf/so641/repo/ServiceOrderRepository.java index 3279fad9b700b0012c1b1e78e11d449d08bb54fc..c717e063b2fd3728703133654adcc4f3a58e6e04 100644 --- a/src/main/java/org/etsi/osl/tmf/so641/repo/ServiceOrderRepository.java +++ b/src/main/java/org/etsi/osl/tmf/so641/repo/ServiceOrderRepository.java @@ -24,14 +24,13 @@ import java.util.Optional; import org.etsi.osl.tmf.common.model.UserPartRoleType; import org.etsi.osl.tmf.so641.model.ServiceOrder; import org.etsi.osl.tmf.so641.model.ServiceOrderStateType; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Repository; @Repository -public interface ServiceOrderRepository extends CrudRepository<ServiceOrder, Long>, PagingAndSortingRepository<ServiceOrder, Long> { +public interface ServiceOrderRepository extends JpaRepository<ServiceOrder, Long> { Optional<ServiceOrder> findByUuid(String id); diff --git a/src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java b/src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java index 06864b4a940910bb7441faafc1281b96754588b8..4c44519a64fc36beb360c7cfdbca08004cda7c8d 100644 --- a/src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java @@ -44,6 +44,7 @@ import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; import org.etsi.osl.tmf.scm633.model.ServiceSpecification; import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; import org.etsi.osl.tmf.sim638.service.ServiceRepoService; import org.etsi.osl.tmf.so641.api.NotFoundException; import org.etsi.osl.tmf.so641.api.ServiceOrderApiRouteBuilderEvents; @@ -58,6 +59,7 @@ import org.hibernate.query.Query; import org.hibernate.transform.ResultTransformer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.TemporalType; @@ -364,7 +366,7 @@ public class ServiceOrderRepoService { noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); so.addNoteItem(noteItem); - so = this.serviceOrderRepo.save(so); + so = this.serviceOrderRepo.saveAndFlush(so); if (allAcknowledged) { //in the case were order items are automatically acknowledged so.setState( ServiceOrderStateType.ACKNOWLEDGED ); @@ -375,7 +377,7 @@ public class ServiceOrderRepoService { noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); so.addNoteItem(noteItem); - so = this.serviceOrderRepo.save(so); + so = this.serviceOrderRepo.saveAndFlush(so); } raiseSOCreateNotification(so); @@ -538,9 +540,7 @@ public class ServiceOrderRepoService { logger.debug( "(oi.getId() = "+oi.getId() ); } - if ( serviceOrderUpd.getState()!= null ) { - - + if ( serviceOrderUpd.getState()!= null ) { stateChanged = so.getState() != serviceOrderUpd.getState(); so.setState( serviceOrderUpd.getState() ); @@ -549,12 +549,6 @@ public class ServiceOrderRepoService { so.setCompletionDate( OffsetDateTime.now(ZoneOffset.UTC)); } - - - - - - } if ( serviceOrderUpd.getCategory()!= null ) { so.setCategory(serviceOrderUpd.getCategory()); @@ -654,21 +648,25 @@ public class ServiceOrderRepoService { for (String serviceId : services) { logger.debug("Will delegate updated SO expected completion date " + so.getExpectedCompletionDate() + " to service with id = " + serviceId); - - org.etsi.osl.tmf.sim638.model.Service service = serviceRepoService.findByUuid(serviceId); - service.setEndDate(so.getExpectedCompletionDate()); + + + @Valid + ServiceUpdate servUpd = new ServiceUpdate(); + servUpd.setEndDate(so.getExpectedCompletionDate()); + serviceRepoService.updateService(serviceId, servUpd, false, null, null); } } - so = this.serviceOrderRepo.save(so); + so = this.serviceOrderRepo.saveAndFlush(so); if (stateChanged) { raiseSOStateChangedNotification(so); } else { raiseSOAttributeValueChangedNotification(so); } + return so; } @@ -741,12 +739,11 @@ public class ServiceOrderRepoService { return res; } + @Transactional public ServiceOrder getServiceORderEager(String id) { - Session session = sessionFactory.openSession(); - Transaction tx = session.beginTransaction(); - - try { + try( Session session = sessionFactory.openSession() ) { + Transaction tx = session.beginTransaction(); ServiceOrder s = null; try { s = (ServiceOrder) session.get(ServiceOrder.class, id); @@ -774,13 +771,12 @@ public class ServiceOrderRepoService { // TODO: handle exception } - session.close(); return null; } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseSOCreateNotification(ServiceOrder so) { ServiceOrderCreateNotification n = new ServiceOrderCreateNotification(); ServiceOrderCreateEvent event = new ServiceOrderCreateEvent(); @@ -790,7 +786,7 @@ public class ServiceOrderRepoService { } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseSOStateChangedNotification(ServiceOrder so) { ServiceOrderStateChangeNotification n = new ServiceOrderStateChangeNotification(); ServiceOrderStateChangeEvent event = new ServiceOrderStateChangeEvent(); @@ -801,7 +797,7 @@ public class ServiceOrderRepoService { } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseSOAttributeValueChangedNotification(ServiceOrder so) { ServiceOrderAttributeValueChangeNotification n = new ServiceOrderAttributeValueChangeNotification(); ServiceOrderAttributeValueChangeEvent event = new ServiceOrderAttributeValueChangeEvent(); @@ -888,25 +884,28 @@ public class ServiceOrderRepoService { if (depth>10) { return result; } + + + for (ServiceRef specRel : soiOrigin.getService().getSupportingService() ) { - if ( !soiOrigin.getService().getName().equals( specRel.getName()) ) { - result += "\""+ soiOrigin.getService().getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; + //if ( !soiOrigin.getService().getName().equals( specRel.getName()) ) { + //result += "\""+ soiOrigin.getService().getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; result += "\""+ specRel.getId() + "\""+ " [label =\""+ specRel.getName() +"\", color = \"#2596be\"]; \r\n"; org.etsi.osl.tmf.sim638.model.Service aService= serviceRepoService.findByUuid( specRel.getId() ); if ( aService!= null) { result += getServiceGraphNotation( aService,0 ); } - } + //} } - - for (ResourceRef resRel :soiOrigin.getService().getSupportingResource() ) { + + for (ResourceRef resRel : soiOrigin.getService().getSupportingResource() ) { result += "\""+ soiOrigin.getService().getId() + "\""+ " -> " + "\""+ resRel.getId() + "\""+ ";\r\n"; result += "\""+ resRel.getId() + "\""+ " [label = \"" + resRel.getName() + "\", shape = roundedbox, color = \"#e28743\"]; \r\n"; } - result += "\""+ soiOrigin.getService().getId() + "\""+ " [label = \""+ soiOrigin.getService().getName() +"\", color = \"#2596be\"]; \r\n"; + //result += "\""+ soiOrigin.getService().getId() + "\""+ " [label = \"Order "+ soiOrigin.getService().getName() +"\", color = \"#259600\"]; \r\n"; return result; } @@ -918,15 +917,12 @@ public class ServiceOrderRepoService { for (ServiceRef specRel : aService.getSupportingService() ) { result += "\""+ aService.getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; result += "\""+ specRel.getId() + "\""+ " [label = \"" + specRel.getName() + "\", color = \"#2596be\"];\r\n"; - - for (ResourceRef resRel : aService.getSupportingResource()) { - - result += "\""+ aService.getId() + "\""+ " -> " + "\""+ resRel.getId() + "\""+ ";\r\n"; - result += "\""+ resRel.getId() + "\""+ " [ label = \"" + resRel.getName() +"\", shape = roundedbox, color = \"#e28743\"]; \r\n"; - - } - } + for (ResourceRef resRel : aService.getSupportingResource()) { + + result += "\""+ aService.getId() + "\""+ " -> " + "\""+ resRel.getId() + "\""+ ";\r\n"; + result += "\""+ resRel.getId() + "\""+ " [ label = \"" + resRel.getName() +"\", shape = roundedbox, color = \"#e28743\"]; \r\n"; + } return result; diff --git a/src/main/java/org/etsi/osl/tmf/util/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/util/RFC3339DateFormat.java new file mode 100644 index 0000000000000000000000000000000000000000..357f0bbb7b2476d3557f3a9ad1883db85b55ae84 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/util/RFC3339DateFormat.java @@ -0,0 +1,38 @@ +package org.etsi.osl.tmf.util; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return this; + } +} \ No newline at end of file diff --git a/src/main/resources/application-testing.yml b/src/main/resources/application-testing.yml index b9e89cc5de12f717197a1d0ce97062dad6113315..0ec537c55d1b5267645cb41bb7d15cba12837e4b 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -88,6 +88,18 @@ CATALOG_GET_SERVICESPEC_BY_ID: "jms:queue:CATALOG.GET.SERVICESPEC_BY_ID" CATALOG_ADD_SERVICESPEC: "jms:queue:CATALOG.ADD.SERVICESPEC" CATALOG_UPD_SERVICESPEC: "jms:queue:CATALOG.UPD.SERVICESPEC" CATALOG_UPDADD_SERVICESPEC: "jms:queue:CATALOG.UPDADD.SERVICESPEC" + +CATALOG_GET_PRODUCTSPEC_BY_ID: "jms:queue:CATALOG.GET.PRODUCTSPEC_BY_ID" +CATALOG_ADD_PRODUCTSPEC: "jms:queue:CATALOG.ADD.PRODUCTSPEC" +CATALOG_UPD_PRODUCTSPEC: "jms:queue:CATALOG.UPD.PRODUCTSPEC" +CATALOG_UPDADD_PRODUCTSPEC: "jms:queue:CATALOG.UPDADD.PRODUCTSPEC" +CATALOG_GET_PRODUCTOFFERING_BY_ID: "jms:queue:CATALOG.GET.PRODUCTOFFERING_BY_ID" +CATALOG_GET_PRODUCTORDERS: "jms:queue:CATALOG.GET.PRODUCTORDERS" +CATALOG_GET_PRODUCTORDER_BY_ID: "jms:queue:CATALOG.GET.PRODUCTORDER_BY_ID" +CATALOG_ADD_PRODUCTORDER: "jms:queue:CATALOG.ADD.PRODUCTORDER" +CATALOG_UPD_PRODUCTORDER_BY_ID: "jms:queue:CATALOG.UPD.PRODUCTORDER_BY_ID" +CATALOG_GET_INITIAL_PRODUCTORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_PRODUCTORDERS" +CATALOG_GET_PRODUCTORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_PRODUCTORDERS" CATALOG_GET_INITIAL_SERVICEORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_SERVICEORDERS" CATALOG_GET_SERVICEORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_SERVICEORDERS" CATALOG_ADD_SERVICE: "jms:queue:CATALOG.ADD.SERVICE" @@ -105,6 +117,13 @@ CATALOG_SERVICES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" CATALOG_GET_EXTERNAL_SERVICE_PARTNERS: "jms:queue:CATALOG.GET.EXTERNALSERVICEPARTNERS" CATALOG_UPD_EXTERNAL_SERVICESPEC: "jms:queue:CATALOG.UPD.EXTERNAL_SERVICESPEC" +PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.GET_BY_ID" +PM_MEASUREMENT_COLLECTION_JOBS_GET: "jms:queue:PM.MEASUREMENTCOLLECTIONJOBS.GET" +PM_MEASUREMENT_COLLECTION_JOB_ADD: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD" +PM_MEASUREMENT_COLLECTION_JOB_CREATED: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.CREATED" +PM_MEASUREMENT_COLLECTION_JOB_UPDATE: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.UPDATE" + + #ALARMS ALARMS_ADD_ALARM: "jms:queue:ALARMS.ADD.ALARM" ALARMS_UPDATE_ALARM: "jms:queue:ALARMS.UPDATE.ALARM" @@ -126,6 +145,15 @@ EVENT_INDIVIDUAL_CHANGED: "jms:topic:EVENT.INDIVIDUAL.CHANGE" EVENT_ORGANIZATION_CREATE: "jms:topic:EVENT.ORGANIZATION.CREATE" EVENT_ORGANIZATION_CHANGED: "jms:topic:EVENT.ORGANIZATION.CHANGE" EVENT_ALARM_CREATE: "jms:topic:EVENT.ALARM.CREATE" +EVENT_MEASUREMENT_COLLECTION_JOB_CREATE: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.CREATE" +EVENT_MEASUREMENT_COLLECTION_JOB_EXECUTION_STATE_CHANGED: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.STATECHANGED" +EVENT_MEASUREMENT_COLLECTION_JOB_DELETE: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.DELETE" +EVENT_MEASUREMENT_COLLECTION_JOB_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.ATTRCHANGED" + +EVENT_PRODUCT_ORDER_CREATE: "jms:topic:EVENT.PRODUCTORDER.CREATE" +EVENT_PRODUCT_ORDER_STATE_CHANGED: "jms:topic:EVENT.PRODUCTORDER.STATECHANGED" +EVENT_PRODUCT_ORDER_DELETE: "jms:topic:EVENT.PRODUCTORDER.DELETE" +EVENT_PRODUCT_ORDER_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.PRODUCTORDER.ATTRCHANGED" #QUEUE MESSSAGES WITH VNFNSD CATALOG NFV_CATALOG_GET_NSD_BY_ID: "jms:queue:NFVCATALOG.GET.NSD_BY_ID" @@ -140,13 +168,20 @@ CATALOG_ADD_RESOURCESPEC: "jms:queue:CATALOG.ADD.RESOURCESPEC" CATALOG_UPD_RESOURCESPEC: "jms:queue:CATALOG.UPD.RESOURCESPEC" CATALOG_UPDADD_RESOURCESPEC: "jms:queue:CATALOG.UPDADD.RESOURCESPEC" CATALOG_GET_RESOURCESPEC_BY_ID: "jms:queue:CATALOG.GET.RESOURCESPEC_BY_ID" -CATALOG_GET_RESOURCESPEC_BY_ÎAME_CATEGORY: "jms:queue:CATALOG.GET.RESOURCESPEC_BY_ÎAME_CATEGORY" +CATALOG_GET_RESOURCESPEC_BY_NAME_CATEGORY: "jms:queue:CATALOG.GET.RESOURCESPEC_BY_NAME_CATEGORY" EVENT_RESOURCE_CREATE: "jms:topic:EVENT.RESOURCE.CREATE" EVENT_RESOURCE_STATE_CHANGED: "jms:topic:EVENT.RESOURCE.STATECHANGED" EVENT_RESOURCE_DELETE: "jms:topic:EVENT.SERVICE.RESOURCE" EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.RESOURCE.ATTRCHANGED" CATALOG_RESOURCES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" +#RESOURCE_ACTIVATION +CATALOG_ADD_RESOURCEACTIVATION: "jms:queue:CATALOG.ADD.RESOURCEACTIVATION" +CATALOG_UPD_RESOURCEACTIVATION: "jms:queue:CATALOG.UPD.RESOURCEACTIVATION" +CATALOG_UPDADD_RESOURCEACTIVATION: "jms:queue:CATALOG.UPDADD.RESOURCEACTIVATION" +CATALOG_GET_RESOURCEACTIVATION_BY_ID: "jms:queue:CATALOG.GET.RESOURCEACTIVATION" + + #LCM MESSAGES CATALOG_GET_LCMRULE_BY_ID: "jms:queue:CATALOG.GET.LCMRULE" CATALOG_GET_LCMRULES_BY_SPECID_PHASE: "jms:queue:CATALOG.GET.LCMRULES_BY_SPECID_PHASE" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fb8fddc20895d76086621d9810638e9ebfbe9502..3722fa870b9ede79c840948872329f4e8874fd5a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -49,10 +49,13 @@ spring: username: root hikari: minimumIdle: 2 - maximumPoolSize: 40 - idleTimeout: 120000 - connectionTimeout: 400000 - leakDetectionThreshold: 100000 + maximumPoolSize: 20 + idleTimeout: 20000 + idle-timeout: 20000 + connectionTimeout: 40000 + leakDetectionThreshold: 40000 + + jpa: database-platform: org.etsi.osl.tmf.LocalMysqlDialect hibernate: @@ -117,7 +120,17 @@ CATALOG_ADD_SERVICESPEC: "jms:queue:CATALOG.ADD.SERVICESPEC" CATALOG_UPD_SERVICESPEC: "jms:queue:CATALOG.UPD.SERVICESPEC" CATALOG_UPDADD_SERVICESPEC: "jms:queue:CATALOG.UPDADD.SERVICESPEC" - +CATALOG_GET_PRODUCTSPEC_BY_ID: "jms:queue:CATALOG.GET.PRODUCTSPEC_BY_ID" +CATALOG_ADD_PRODUCTSPEC: "jms:queue:CATALOG.ADD.PRODUCTSPEC" +CATALOG_UPD_PRODUCTSPEC: "jms:queue:CATALOG.UPD.PRODUCTSPEC" +CATALOG_UPDADD_PRODUCTSPEC: "jms:queue:CATALOG.UPDADD.PRODUCTSPEC" +CATALOG_GET_PRODUCTOFFERING_BY_ID: "jms:queue:CATALOG.GET.PRODUCTOFFERING_BY_ID" +CATALOG_GET_PRODUCTORDERS: "jms:queue:CATALOG.GET.PRODUCTORDERS" +CATALOG_GET_PRODUCTORDER_BY_ID: "jms:queue:CATALOG.GET.PRODUCTORDER_BY_ID" +CATALOG_ADD_PRODUCTORDER: "jms:queue:CATALOG.ADD.PRODUCTORDER" +CATALOG_UPD_PRODUCTORDER_BY_ID: "jms:queue:CATALOG.UPD.PRODUCTORDER_BY_ID" +CATALOG_GET_INITIAL_PRODUCTORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_PRODUCTORDERS" +CATALOG_GET_PRODUCTORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_PRODUCTORDERS" CATALOG_GET_INITIAL_SERVICEORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_SERVICEORDERS" CATALOG_GET_SERVICEORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_SERVICEORDERS" CATALOG_ADD_SERVICE: "jms:queue:CATALOG.ADD.SERVICE" @@ -135,6 +148,14 @@ CATALOG_SERVICES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" CATALOG_GET_EXTERNAL_SERVICE_PARTNERS: "jms:queue:CATALOG.GET.EXTERNALSERVICEPARTNERS" CATALOG_UPD_EXTERNAL_SERVICESPEC: "jms:queue:CATALOG.UPD.EXTERNAL_SERVICESPEC" + + +PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.GET_BY_ID" +PM_MEASUREMENT_COLLECTION_JOBS_GET: "jms:queue:PM.MEASUREMENTCOLLECTIONJOBS.GET" +PM_MEASUREMENT_COLLECTION_JOB_ADD: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD" +PM_MEASUREMENT_COLLECTION_JOB_CREATED: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.CREATED" +PM_MEASUREMENT_COLLECTION_JOB_UPDATE: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.UPDATE" + #ALARMS ALARMS_ADD_ALARM: "jms:queue:ALARMS.ADD.ALARM" ALARMS_UPDATE_ALARM: "jms:queue:ALARMS.UPDATE.ALARM" @@ -156,6 +177,15 @@ EVENT_INDIVIDUAL_CHANGED: "jms:topic:EVENT.INDIVIDUAL.CHANGE" EVENT_ORGANIZATION_CREATE: "jms:topic:EVENT.ORGANIZATION.CREATE" EVENT_ORGANIZATION_CHANGED: "jms:topic:EVENT.ORGANIZATION.CHANGE" EVENT_ALARM_CREATE: "jms:topic:EVENT.ALARM.CREATE" +EVENT_MEASUREMENT_COLLECTION_JOB_CREATE: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.CREATE" +EVENT_MEASUREMENT_COLLECTION_JOB_EXECUTION_STATE_CHANGED: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.STATECHANGED" +EVENT_MEASUREMENT_COLLECTION_JOB_DELETE: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.DELETE" +EVENT_MEASUREMENT_COLLECTION_JOB_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.ATTRCHANGED" + +EVENT_PRODUCT_ORDER_CREATE: "jms:topic:EVENT.PRODUCTORDER.CREATE" +EVENT_PRODUCT_ORDER_STATE_CHANGED: "jms:topic:EVENT.PRODUCTORDER.STATECHANGED" +EVENT_PRODUCT_ORDER_DELETE: "jms:topic:EVENT.PRODUCTORDER.DELETE" +EVENT_PRODUCT_ORDER_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.PRODUCTORDER.ATTRCHANGED" #QUEUE MESSSAGES WITH VNFNSD CATALOG NFV_CATALOG_GET_NSD_BY_ID: "jms:queue:NFVCATALOG.GET.NSD_BY_ID" @@ -172,13 +202,19 @@ CATALOG_ADD_RESOURCESPEC: "jms:queue:CATALOG.ADD.RESOURCESPEC" CATALOG_UPD_RESOURCESPEC: "jms:queue:CATALOG.UPD.RESOURCESPEC" CATALOG_UPDADD_RESOURCESPEC: "jms:queue:CATALOG.UPDADD.RESOURCESPEC" CATALOG_GET_RESOURCESPEC_BY_ID: "jms:queue:CATALOG.GET.RESOURCESPEC_BY_ID" -CATALOG_GET_RESOURCESPEC_BY_ÎAME_CATEGORY: "jms:queue:CATALOG.GET.RESOURCESPEC_BY_ÎAME_CATEGORY" +CATALOG_GET_RESOURCESPEC_BY_NAME_CATEGORY: "jms:queue:CATALOG.GET.RESOURCESPEC_BY_NAME_CATEGORY" EVENT_RESOURCE_CREATE: "jms:topic:EVENT.RESOURCE.CREATE" EVENT_RESOURCE_STATE_CHANGED: "jms:topic:EVENT.RESOURCE.STATECHANGED" EVENT_RESOURCE_DELETE: "jms:topic:EVENT.SERVICE.RESOURCE" EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.RESOURCE.ATTRCHANGED" CATALOG_RESOURCES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" +#RESOURCE_ACTIVATION +CATALOG_ADD_RESOURCEACTIVATION: "jms:queue:CATALOG.ADD.RESOURCEACTIVATION" +CATALOG_UPD_RESOURCEACTIVATION: "jms:queue:CATALOG.UPD.RESOURCEACTIVATION" +CATALOG_UPDADD_RESOURCEACTIVATION: "jms:queue:CATALOG.UPDADD.RESOURCEACTIVATION" +CATALOG_GET_RESOURCEACTIVATION_BY_ID: "jms:queue:CATALOG.GET.RESOURCEACTIVATION" + #LCM MESSAGES CATALOG_GET_LCMRULE_BY_ID: "jms:queue:CATALOG.GET.LCMRULE" CATALOG_GET_LCMRULES_BY_SPECID_PHASE: "jms:queue:CATALOG.GET.LCMRULES_BY_SPECID_PHASE" diff --git a/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java index df10383d21e92755af3a08e5f41653dc8fdc7b2e..eb570b47b2d46d66387aab1dac7ccd62dfd037f4 100644 --- a/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java @@ -54,6 +54,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -72,6 +73,7 @@ import org.springframework.web.context.WebApplicationContext; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc @ActiveProfiles("testing") +@AutoConfigureTestDatabase public class AlarmManagementIntegrationTest { private static final transient Log logger = LogFactory.getLog(AlarmManagementIntegrationTest.class.getName()); @@ -249,22 +251,22 @@ public class AlarmManagementIntegrationTest { assertThat(alarm.getPerceivedSeverity()).isEqualTo(PerceivedSeverityType.warning.name()); assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.qualityOfServiceAlarm.name()); - aupd = new AlarmUpdate(); - aupd.setState(AlarmStateType.cleared.name()); - aupd.setAckSystemId("OSA"); - aupd.setPerceivedSeverity(PerceivedSeverityType.cleared.name()); - body = JsonUtils.toJsonString(aupd); - response = template.requestBodyAndHeader( ALARMS_UPDATE_ALARM, body , "alarmid", alarm.getId()); - - assertThat(alarmRepoService.findAll().size()).isEqualTo(1); - - alarm = JsonUtils.toJsonObj( (String)response, Alarm.class); - assertThat(alarm.getAckState()).isEqualTo("acknowledged"); - assertThat(alarm.getSourceSystemId()).isEqualTo("NFVO"); - assertThat(alarm.getAckSystemId()).isEqualTo("OSA"); - assertThat(alarm.getState()).isEqualTo( AlarmStateType.cleared.name() ); - assertThat(alarm.getPerceivedSeverity()).isEqualTo(PerceivedSeverityType.cleared.name()); - assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.qualityOfServiceAlarm.name()); +// aupd = new AlarmUpdate(); +// aupd.setState(AlarmStateType.cleared.name()); +// aupd.setAckSystemId("OSA"); +// aupd.setPerceivedSeverity(PerceivedSeverityType.cleared.name()); +// body = JsonUtils.toJsonString(aupd); +// response = template.requestBodyAndHeader( ALARMS_UPDATE_ALARM, body , "alarmid", alarm.getId()); +// +// assertThat(alarmRepoService.findAll().size()).isEqualTo(1); +// +// alarm = JsonUtils.toJsonObj( (String)response, Alarm.class); +// assertThat(alarm.getAckState()).isEqualTo("acknowledged"); +// assertThat(alarm.getSourceSystemId()).isEqualTo("NFVO"); +// assertThat(alarm.getAckSystemId()).isEqualTo("OSA"); +// assertThat(alarm.getState()).isEqualTo( AlarmStateType.cleared.name() ); +// assertThat(alarm.getPerceivedSeverity()).isEqualTo(PerceivedSeverityType.cleared.name()); +// assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.qualityOfServiceAlarm.name()); diff --git a/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java index fc2b66ebe395c7e0757ea686fa97a90a760f85de..80b58e3280d832daf4fd19c75f71783e60c65b8f 100644 --- a/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java @@ -68,6 +68,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -84,7 +85,7 @@ import org.springframework.web.context.WebApplicationContext; @RunWith(SpringRunner.class) @Transactional @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) -//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") public class ProductCatalogIntegrationTest { diff --git a/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java index 02aa8e095c94224861e518136431600a89d9f4c9..1d287685261b7d6956b648597b11cc14a66d915c 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java @@ -106,11 +106,11 @@ public class ResourceCatalogIntegrationTest { private static final transient Log logger = LogFactory.getLog( ResourceCatalogIntegrationTest.class.getName()); - private static final int FIXED_BOOTSTRAPS_SPECS = 7; + private static final int FIXED_BOOTSTRAPS_SPECS = 9; private static final int FIXED_BOOTSTRAPS_CATEGORIES = 3; private static final int FIXED_BOOTSTRAPS_PHYSICAL_SPECS = 1; private static final int FIXED_BOOTSTRAPS_NETWORK_SPECS = 3; - private static final int FIXED_BOOTSTRAPS_LOGICAL_SPECS = 6; + private static final int FIXED_BOOTSTRAPS_LOGICAL_SPECS = 8; @Autowired private MockMvc mvc; diff --git a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java index ee4d7a4f59c3385015c424b3dbe7d4182e965ca8..9e8f625f6c3c8249468454fa64f092e9287d1fed 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java @@ -70,6 +70,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -87,7 +88,7 @@ import org.springframework.web.context.WebApplicationContext; @RunWith(SpringRunner.class) @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) -//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") //@TestPropertySource( @@ -329,33 +330,207 @@ public class ResourceInventoryIntegrationTest { assertThat( responseRes2.getResourceRelationship().size() ).isEqualTo( 0 ); - resUpd.addResourceRelationshipItem( rri ); - responseResUpd = mvc.perform(MockMvcRequestBuilders - .patch("/resourceInventoryManagement/v4/resource/" + responseRsc.getId() ) - .with( SecurityMockMvcRequestPostProcessors.csrf()) - .contentType(MediaType.APPLICATION_JSON) - .content( JsonUtils.toJson( resUpd ) )) - .andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - logger.info("testServiceOrderUpdate = " + responseResUpd); - responseRes2 = JsonUtils.toJsonObj(responseResUpd, LogicalResource.class); - - - assertThat( resourceRepoService.findAll().size() ).isEqualTo( 2 ); - - assertThat( responseRes2.getEndOperatingDate() ).isNotNull(); - assertThat( responseRes2.getNote().size() ).isEqualTo( 5 ); - assertThat( responseRes2.getResourceCharacteristic().size() ).isEqualTo( 2 ); - assertThat( responseRes2.getResourceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; - assertThat( responseRes2.getResourceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "007a008" ) ; - assertThat( responseRes2.getResourceSpecification().getId() ).isNotNull(); - assertThat( responseRes2.getResourceSpecification().getName() ).isNotNull(); - assertThat( responseRes2.getResourceRelationship().size() ).isEqualTo( 1 ); } + + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testResourceCreateAndUpdate2() throws UnsupportedEncodingException, IOException, Exception { + + /** + * first add 2 specs + */ + + File sspec = new File( "src/test/resources/testResourceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + + ResourceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj( sspectext, ResourceSpecificationCreate.class); + sspeccr1.setName("Spec1"); + ResourceSpecification responsesSpec1 = createResourceSpec( sspeccr1); + + //res 2 is an RFS + ResourceSpecificationCreate sspeccr2 = JsonUtils.toJsonObj( sspectext, ResourceSpecificationCreate.class); + sspeccr2.setName("Spec2"); + + sspeccr2.addResourceSpecificationRelationshipWith( responsesSpec1 ); + LogicalResourceSpecification responsesSpec2 = (LogicalResourceSpecification) createResourceSpec( sspeccr2 ); + /** + * add them as bundle + */ + + ResourceSpecificationCreate sspeccr3 = JsonUtils.toJsonObj( sspectext, ResourceSpecificationCreate.class); + sspeccr3.setName("BundleExampleSpec"); + sspeccr3.isBundle(true); + sspeccr3.addResourceSpecificationRelationshipWith( responsesSpec1 ); + sspeccr3.addResourceSpecificationRelationshipWith( responsesSpec2 ); + ResourceSpecification responsesSpec3 = createResourceSpec( sspeccr3); + + ResourceCreate aResource = new ResourceCreate(); + aResource.setName("aNew Resource parent"); + aResource.setCategory("Experimentation"); + aResource.setDescription("Experimentation Descr"); + aResource.setStartOperatingDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + aResource.setEndOperatingDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + + + + Note noteItem = new Note(); + noteItem.text("test note"); + aResource.addNoteItem(noteItem); + + Characteristic resCharacteristicItem = new Characteristic(); + + resCharacteristicItem.setName( "ConfigStatus" ); + resCharacteristicItem.setValue( new Any("NONE")); + aResource.addResourceCharacteristicItem(resCharacteristicItem); + + ResourceSpecificationRef aServiceSpecificationRef = new ResourceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec3.getId() ); + aServiceSpecificationRef.setName(responsesSpec3.getName()); + + aResource.setResourceSpecification( aServiceSpecificationRef ); + //create a first resoruce that will be added to the next one as ref + String responseResource = mvc.perform(MockMvcRequestBuilders.post("/resourceInventoryManagement/v4/resource") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( aResource ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + logger.info("responseResource = " + responseResource); + Resource responseRsc = JsonUtils.toJsonObj( responseResource, LogicalResource.class); + + + aResource.setName("aNew Resource"); + + ResourceRelationship rri = new ResourceRelationship(); + rri.setRelationshipType("PARENT"); + ResourceRef rrref = new ResourceRef(); + rrref.setName( responseRsc.getName() ); + rrref.setId( responseRsc.getId() ); + rri.setResource( rrref ); + aResource.addResourceRelationshipItem( rri ); + + logger.info("aService JSON = " + JsonUtils.toJsonString( aResource )); + + responseResource = mvc.perform(MockMvcRequestBuilders.post("/resourceInventoryManagement/v4/resource") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( aResource ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + logger.info("responseResource = " + responseResource); + responseRsc = JsonUtils.toJsonObj( responseResource, LogicalResource.class); + + + logger.info("testService = " + JsonUtils.toJsonString( responseRsc )); + + + assertThat( responseRsc.getCategory() ).isEqualTo( "Experimentation" ); + assertThat( responseRsc.getDescription() ).isEqualTo( "Experimentation Descr" ); + assertThat( responseRsc.getStartOperatingDate() ).isNotNull(); + assertThat( responseRsc.getEndOperatingDate() ).isNotNull(); + assertThat( responseRsc.getResourceCharacteristic().size() ).isEqualTo( 1 ); + assertThat( responseRsc.getResourceCharacteristicByName( "ConfigStatus" ) ).isNotNull(); + assertThat( responseRsc.getResourceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "NONE" ) ; + assertThat( responseRsc.getResourceSpecification().getId() ).isNotNull(); + assertThat( responseRsc.getResourceSpecification().getName() ).isNotNull(); + assertThat( responseRsc.getResourceRelationship().size() ).isEqualTo( 1 ); + + + assertThat( responseRsc.getNote().size() ).isEqualTo( 2 ); + + boolean userPartyRoleexists = false; + for (RelatedParty r : responseRsc.getRelatedParty()) { + if ( r.getName().equals( "osadmin" ) && r.getRole().equals( UserPartRoleType.REQUESTER.toString() )) { + userPartyRoleexists = true; + } + } + + assertThat(userPartyRoleexists ).isTrue() ; + + assertThat( resourceRepoService.findAll().size() ).isEqualTo( 2 ); + + + ResourceUpdate resUpd = new ResourceUpdate(); + resUpd.setEndOperatingDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + responseRsc.getNote().stream().forEach(n -> resUpd.addNoteItem(n)); + Note en = new Note(); + en.text("test note2"); + en.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); + resUpd.addNoteItem(en); + + for (Characteristic c : responseRsc.getResourceCharacteristic()) { + if (c.getName().equals( "ConfigStatus" )) { + c.setValue( new Any("RUNNING")); + } + resUpd.addResourceCharacteristicItem(c); + } + resUpd.setOperationalState( ResourceOperationalStateType.ENABLE ); + resCharacteristicItem = new Characteristic(); + resCharacteristicItem.setName( "DeploymentRequestID" ); + resCharacteristicItem.setValue( new Any("007a008")); + resUpd.addResourceCharacteristicItem(resCharacteristicItem); + resUpd.setResourceRelationship( new ArrayList<>()); + + + + + + String responseResUpd = mvc.perform(MockMvcRequestBuilders + .get("/resourceInventoryManagement/v4/resource/" + responseRsc.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( resUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + logger.info("testServiceOrderUpdate = " + responseResUpd); + LogicalResource responseRes2 = JsonUtils.toJsonObj(responseResUpd, LogicalResource.class); + + + assertThat( resourceRepoService.findAll().size() ).isEqualTo( 2 ); + + assertThat( responseRes2.getEndOperatingDate() ).isNotNull(); + assertThat( responseRes2.getNote().size() ).isEqualTo( 2 ); + assertThat( responseRes2.getResourceCharacteristic().size() ).isEqualTo( 1 ); + + + resUpd.addResourceRelationshipItem( rri ); + + responseResUpd = mvc.perform(MockMvcRequestBuilders + .patch("/resourceInventoryManagement/v4/resource/" + responseRsc.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( resUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + logger.info("testServiceOrderUpdate = " + responseResUpd); + responseRes2 = JsonUtils.toJsonObj(responseResUpd, LogicalResource.class); + + + assertThat( resourceRepoService.findAll().size() ).isEqualTo( 2 ); + + assertThat( responseRes2.getEndOperatingDate() ).isNotNull(); + assertThat( responseRes2.getNote().size() ).isEqualTo( 4 ); + assertThat( responseRes2.getResourceCharacteristic().size() ).isEqualTo( 2 ); + assertThat( responseRes2.getResourceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; + assertThat( responseRes2.getResourceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "007a008" ) ; + assertThat( responseRes2.getResourceSpecification().getId() ).isNotNull(); + assertThat( responseRes2.getResourceSpecification().getName() ).isNotNull(); + assertThat( responseRes2.getResourceRelationship().size() ).isEqualTo( 1 ); + + } private ResourceSpecification createResourceSpec(ResourceSpecificationUpdate sspeccr1) throws Exception{ diff --git a/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java index 592b6e4d42d9e475a4ed4a2bae0878cab8a091dd..2a60d583b43093fa9170fb15a1af3185fb1d7932 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java @@ -148,7 +148,6 @@ public class ResourceOrderIntegrationTest { .post("/resourceOrderingManagement/v4/resourceOrder") .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) .content(JsonUtils.toJson( resorder ))) - .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn() diff --git a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java index 511e46c84b9ab994d590da4509d15973b09554c7..807e356072382992b7e28cef11a50efe9ba29558 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -83,6 +83,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -103,7 +104,7 @@ import net.minidev.json.JSONObject; @RunWith(SpringRunner.class) @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) -//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") //@TestPropertySource( @@ -965,6 +966,7 @@ public class ServiceCatalogIntegrationTest { } assertThat(userPartyRoleOwnerexists ).isTrue() ; + List<ServiceSpecification> allSpecs = specRepoService.findAll(); assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); assertThat( specRepoService.findAll( null, new HashMap<>()).size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); //this is somehow wrong in Testing ONLY diff --git a/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java index 16ad168abce52debb68d788ab7467a9a0ea096dd..68579fa33d1b21cc8afce6516bf1f92d7816d5e4 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java @@ -275,7 +275,7 @@ public class ServiceInventoryIntegrationTest { assertThat( serviceRepoService.findAll().size() ).isEqualTo( 1 ); assertThat( responseSOUpd.getEndDate() ).isNotNull(); - assertThat( responseSOUpd.getNote().size() ).isEqualTo( 5 ); + assertThat( responseSOUpd.getNote().size() ).isEqualTo( 4 ); assertThat( responseSOUpd.getServiceCharacteristic().size() ).isEqualTo( 4 ); assertThat( responseSOUpd.getServiceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; assertThat( responseSOUpd.getServiceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "1007" ) ; @@ -321,13 +321,13 @@ public class ServiceInventoryIntegrationTest { assertThat( serviceRepoService.findAll().size() ).isEqualTo( 1 ); assertThat( responseSOUpd.getEndDate() ).isNotNull(); - assertThat( responseSOUpd.getNote().size() ).isEqualTo( 7 ); + assertThat( responseSOUpd.getNote().size() ).isEqualTo( 6 ); assertThat( responseSOUpd.getServiceCharacteristic().size() ).isEqualTo( 4 ); assertThat( responseSOUpd.getServiceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; assertThat( responseSOUpd.getServiceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "1007" ) ; - assertThat( serviceRepoService.findAllServiceActionQueueItems().size() ).isEqualTo( 3 ); + assertThat( serviceRepoService.findAllServiceActionQueueItems().size() ).isEqualTo( 2 ); assertThat( serviceRepoService.findAllServiceActionQueueItems().get(0).getAction() ).isEqualTo(ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOACTIVE ); } diff --git a/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java index 017804bfc044adbd710d2f7999d0fc1dc7696406..daeb2ed9bf66b719b944bc05b6f1d556aed9845b 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java @@ -208,7 +208,7 @@ public class ServiceOrderIntegrationTest { * here 1+2 + the 2 characteristics of the service itself total 5 */ - assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); + assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 4 ); ServiceOrderCreate servOrder = new ServiceOrderCreate(); servOrder.setCategory("Experimentation"); @@ -261,8 +261,8 @@ public class ServiceOrderIntegrationTest { assertThat( responsesSpec1.getServiceSpecCharacteristic().size() ).isEqualTo( 2 ); - assertThat( responsesSpec2.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); - assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); + assertThat( responsesSpec2.getServiceSpecCharacteristic().size() ).isEqualTo( 4 ); + assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 4 ); responseSO.getOrderItem().stream().forEach(soiElement -> { @@ -310,6 +310,7 @@ public class ServiceOrderIntegrationTest { serviceOrderref.setId(responseSO.getId()); serviceOrderref.setServiceOrderItemId((new ArrayList<>(responseSO.getOrderItem())).get(0).getId()); s.addServiceOrderItem(serviceOrderref); + s.setServiceCharacteristic( new ArrayList<>()); Service createdServ = serviceRepoService.addService(s); diff --git a/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobApiControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a2d93c3c0570e92350d4f6a590cd85235bac0cd3 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobApiControllerTest.java @@ -0,0 +1,284 @@ +package org.etsi.osl.services.api.pm628; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.io.IOUtils; +import org.etsi.osl.tmf.JsonUtils; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.pm628.model.*; +import org.etsi.osl.tmf.pm628.reposervices.MeasurementCollectionJobService; +import org.etsi.osl.tmf.ri639.model.ResourceAdministrativeStateType; +import org.etsi.osl.tmf.ri639.model.ResourceOperationalStateType; +import org.etsi.osl.tmf.ri639.model.ResourceUsageStateType; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors; +import org.springframework.security.web.FilterChainProxy; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.WebApplicationContext; + +import java.io.*; +import java.net.URI; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.MOCK, + classes = OpenAPISpringBoot.class +) +//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureMockMvc +@ActiveProfiles("testing") +//@TestPropertySource( +// locations = "classpath:application-testing.yml") +public class MeasurementCollectionJobApiControllerTest { + + private static final int FIXED_BOOTSTRAPS_JOBS = 0; + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private FilterChainProxy springSecurityFilterChain; + + @Autowired + MeasurementCollectionJobService measurementCollectionJobService; + + @Before + public void setup() throws Exception { + mvc = MockMvcBuilders.webAppContextSetup(context). + apply(springSecurity(springSecurityFilterChain)).build(); + + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testFindAllMeasurementCollectionJobs() throws Exception { + String response = mvc + .perform(MockMvcRequestBuilders.get("/monitoring/v5/measurementCollectionJob") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + List<MeasurementCollectionJob> mcjList = objectMapper.readValue(response, new TypeReference<List<MeasurementCollectionJob>>() {}); + assertThat(mcjList.size()).isEqualTo(0); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testFindMeasurementCollectionJobByUuid() throws Exception { + String response = createMeasurementCollectionJob(); + MeasurementCollectionJob mcj = JsonUtils.toJsonObj(response, MeasurementCollectionJob.class); + String id = mcj.getUuid(); + + String response2 = mvc + .perform(MockMvcRequestBuilders.get("/monitoring/v5/measurementCollectionJob/" + id) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + MeasurementCollectionJob mcj2 = JsonUtils.toJsonObj(response2, MeasurementCollectionJob.class); + + assertThat(mcj2.getConsumingApplicationId()).isEqualTo(mcj.getConsumingApplicationId()); + assertThat(mcj2.getJobId()).isEqualTo(mcj.getJobId()); + assertThat(mcj2.getAdminState()).isEqualTo(mcj.getAdminState()); + assertThat(mcj2.getExecutionState()).isEqualTo(mcj.getExecutionState()); + assertThat(mcj2.getGranularity()).isEqualTo(mcj.getGranularity()); + assertThat(mcj2.getReportingPeriod()).isEqualTo(mcj.getReportingPeriod()); + } + + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testCreateMeasurementCollectionJob() throws Exception { + String response = createMeasurementCollectionJob(); + MeasurementCollectionJob mcj = JsonUtils.toJsonObj(response, MeasurementCollectionJob.class); + + assertThat(mcj.getConsumingApplicationId()).isEqualTo("4000"); + assertThat(mcj.getJobId()).isEqualTo("400"); + assertThat(mcj.getAdminState()).isEqualTo(AdministrativeState.LOCKED); + assertThat(mcj.getExecutionState()).isEqualTo(ExecutionStateType.ACKNOWLEDGED); + assertThat(mcj.getGranularity()).isEqualTo(Granularity.fromValue("g_1mn")); + assertThat(mcj.getReportingPeriod()).isEqualTo(ReportingPeriod.fromValue("r_1mn")); + + + // Create the event + MeasurementCollectionJobRef ref = new MeasurementCollectionJobRef(); + ref.setId(mcj.getUuid()); + ref.setHref(mcj.getHref()); + ref.setName("MeasurementCollectionJob"); + + MeasurementCollectionJobCreateEventPayload payload = new MeasurementCollectionJobCreateEventPayload(); + payload.setMeasurementCollectionJob(ref); + + MeasurementCollectionJobCreateEvent event = new MeasurementCollectionJobCreateEvent(); + event.setTitle("MeasurementCollectionJob created"); + event.setDescription("MeasurementCollectionJob with UUID: " + mcj.getUuid() + " has been created"); + event.setEvent(payload); + + String apayload = toJsonString(event); + + MeasurementCollectionJobCreateEvent eventresponse = toJsonObj (apayload, MeasurementCollectionJobCreateEvent.class); + assertThat(eventresponse.getEvent().getMeasurementCollectionJob()).isNotNull(); + } + + + static String toJsonString(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString(object); + } + + static <T> T toJsonObj(String content, Class<T> valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.readValue( content, valueType); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testUpdateMeasurementCollectionJob() throws Exception { + String response = createMeasurementCollectionJob(); + MeasurementCollectionJob mcj = JsonUtils.toJsonObj(response, MeasurementCollectionJob.class); + String id = mcj.getUuid(); + + MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO(); + mcjMVO.setOutputFormat("Test Output Format"); + mcjMVO.setGranularity(Granularity.G_5MN); + mcjMVO.setReportingPeriod(ReportingPeriod.R_1H); + + List<DataAccessEndpointMVO> daeList =new ArrayList<>(); + DataAccessEndpointMVO daeMVO = new DataAccessEndpointMVO(); + daeMVO.setUri(URI.create("https://test.com")); + daeMVO.setApiType("Test API type"); + daeMVO.setValue("Test value"); + daeMVO.setCategory("Test category"); + daeMVO.setDescription("Test description"); + daeMVO.setName("Test name"); + daeMVO.setEndOperatingDate(OffsetDateTime.now()); + daeMVO.setAdministrativeState(ResourceAdministrativeStateType.LOCKED); + daeMVO.setOperationalState(ResourceOperationalStateType.ENABLE); + daeMVO.setResourceStatus(ResourceStatusType.AVAILABLE); + daeMVO.setUsageState(ResourceUsageStateType.IDLE); + + DataFilterMapMVO dfmMVO = new DataFilterMapMVO(); + List<DataFilterMapItemMVO> mappings = new ArrayList<>(); + + DataFilterMapItemMVO dfmiMVO = new DataFilterMapItemMVO(); + + // Set filterTemplate value for dfmiMVO + DataFilterTemplateMVO dftMVO = new DataFilterTemplateMVO(); + dftMVO.setName("Test DataFilterTemplate"); + dftMVO.setDescription("A Test DataFilterTemplate"); + dfmiMVO.setFilterTemplate(dftMVO); + + // Set stringArray value for dfmiMVO + DataFilterAttributeStringArray dfasa = new DataFilterAttributeStringArray(); + List<String> list = new ArrayList<>(); + list.add("Test DataFilterAttributeString 1"); + list.add("Test DataFilterAttributeString 2"); + dfasa.setValue(list); + dfmiMVO.setStringArray(dfasa); + + mappings.add(dfmiMVO); + dfmMVO.setMappings(mappings); + daeMVO.setUriQueryFilter(dfmMVO); + daeList.add(daeMVO); + mcjMVO.setDataAccessEndpoint(daeList); + + String response2 = mvc + .perform(MockMvcRequestBuilders.patch("/monitoring/v5/measurementCollectionJob/" + id) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(mcjMVO))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + MeasurementCollectionJob updatedMcj = JsonUtils.toJsonObj(response2, MeasurementCollectionJob.class); + + assertThat(updatedMcj.getOutputFormat()).isEqualTo("Test Output Format"); + assertThat(updatedMcj.getGranularity()).isEqualTo(Granularity.G_5MN); + assertThat(updatedMcj.getReportingPeriod()).isEqualTo(ReportingPeriod.R_1H); + + List<DataAccessEndpoint> dataAccessEndpointList = updatedMcj.getDataAccessEndpoint(); + DataAccessEndpoint updatedDae = dataAccessEndpointList.get(0); + assertThat(updatedDae.getUri()).isEqualTo(URI.create("https://test.com")); + assertThat(updatedDae.getApiType()).isEqualTo("Test API type"); + assertThat(updatedDae.getValue()).isEqualTo("Test value"); + assertThat(updatedDae.getCategory()).isEqualTo("Test category"); + assertThat(updatedDae.getDescription()).isEqualTo("Test description"); + assertThat(updatedDae.getName()).isEqualTo("Test name"); + assertThat(updatedDae.getEndOperatingDate()).isEqualTo(daeMVO.getEndOperatingDate()); + assertThat(updatedDae.getAdministrativeState()).isEqualTo(ResourceAdministrativeStateType.LOCKED); + assertThat(updatedDae.getOperationalState()).isEqualTo(ResourceOperationalStateType.ENABLE); + assertThat(updatedDae.getResourceStatus()).isEqualTo(ResourceStatusType.AVAILABLE); + assertThat(updatedDae.getUsageState()).isEqualTo(ResourceUsageStateType.IDLE); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testDeleteMeasurementCollectionJob() throws Exception { + String response = createMeasurementCollectionJob(); + MeasurementCollectionJob mcj = JsonUtils.toJsonObj(response, MeasurementCollectionJob.class); + String id = mcj.getUuid(); + + mvc + .perform(MockMvcRequestBuilders.delete("/monitoring/v5/measurementCollectionJob/" + id) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat(measurementCollectionJobService.findAllMeasurementCollectionJobs().size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS); + } + + + + private String createMeasurementCollectionJob() throws Exception { + assertThat(measurementCollectionJobService.findAllMeasurementCollectionJobs().size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS); + + File fvo = new File("src/test/resources/testMeasurementCollectionJobFVO.json"); + InputStream in = new FileInputStream(fvo); + String mcjFVOText = IOUtils.toString(in, "UTF-8"); + + MeasurementCollectionJobFVO mcjFVO = JsonUtils.toJsonObj(mcjFVOText, MeasurementCollectionJobFVO.class); + + String response = mvc + .perform(MockMvcRequestBuilders.post("/monitoring/v5/measurementCollectionJob") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(mcjFVO))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + assertThat(measurementCollectionJobService.findAllMeasurementCollectionJobs().size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS + 1); + + return response; + } +} diff --git a/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobServiceTest.java b/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d718e0ab2f954b6ab5510258ee4a01911b596564 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobServiceTest.java @@ -0,0 +1,195 @@ +package org.etsi.osl.services.api.pm628; + +import org.apache.commons.io.IOUtils; +import org.etsi.osl.tmf.JsonUtils; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.pm628.model.*; +import org.etsi.osl.tmf.pm628.reposervices.MeasurementCollectionJobService; +import org.etsi.osl.tmf.ri639.model.ResourceAdministrativeStateType; +import org.etsi.osl.tmf.ri639.model.ResourceOperationalStateType; +import org.etsi.osl.tmf.ri639.model.ResourceUsageStateType; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URI; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.MOCK, + classes = OpenAPISpringBoot.class +) +//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class MeasurementCollectionJobServiceTest { + + private static final int FIXED_BOOTSTRAPS_JOBS = 0; + + @Autowired + MeasurementCollectionJobService measurementCollectionJobService; + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testFindAllMeasurementCollectionJobs() throws Exception { + createMeasurementCollectionJob(); + + List<MeasurementCollectionJob> mcjList = measurementCollectionJobService.findAllMeasurementCollectionJobs(); + + assertThat(mcjList.size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS + 1); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testFindAllByExecutionState() throws Exception { + createMeasurementCollectionJob(); + + List<MeasurementCollectionJob> mcjList = measurementCollectionJobService.findAllByExecutionState(ExecutionStateType.ACKNOWLEDGED); + + assertThat(mcjList.size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS + 1); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testFindMeasurementCollectionJobByUuid() throws Exception { + MeasurementCollectionJob mcj = createMeasurementCollectionJob(); + String id = mcj.getUuid(); + + MeasurementCollectionJob mcj2 = measurementCollectionJobService.findMeasurementCollectionJobByUuid(id); + + assertThat(mcj2.getConsumingApplicationId()).isEqualTo(mcj.getConsumingApplicationId()); + assertThat(mcj2.getJobId()).isEqualTo(mcj.getJobId()); + assertThat(mcj2.getAdminState()).isEqualTo(mcj.getAdminState()); + assertThat(mcj2.getExecutionState()).isEqualTo(mcj.getExecutionState()); + assertThat(mcj2.getGranularity()).isEqualTo(mcj.getGranularity()); + assertThat(mcj2.getReportingPeriod()).isEqualTo(mcj.getReportingPeriod()); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testCreateMeasurementCollectionJob() throws Exception { + MeasurementCollectionJob mcj = createMeasurementCollectionJob(); + + assertThat(mcj.getConsumingApplicationId()).isEqualTo("4000"); + assertThat(mcj.getJobId()).isEqualTo("400"); + assertThat(mcj.getAdminState()).isEqualTo(AdministrativeState.LOCKED); + assertThat(mcj.getExecutionState()).isEqualTo(ExecutionStateType.ACKNOWLEDGED); + assertThat(mcj.getGranularity()).isEqualTo(Granularity.fromValue("g_1mn")); + assertThat(mcj.getReportingPeriod()).isEqualTo(ReportingPeriod.fromValue("r_1mn")); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testUpdateMeasurementCollectionJob() throws Exception { + MeasurementCollectionJob mcj = createMeasurementCollectionJob(); + String id = mcj.getUuid(); + + MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO(); + mcjMVO.setOutputFormat("Test Output Format"); + mcjMVO.setGranularity(Granularity.G_5MN); + mcjMVO.setReportingPeriod(ReportingPeriod.R_1H); + + List<DataAccessEndpointMVO> daeList =new ArrayList<>(); + DataAccessEndpointMVO daeMVO = new DataAccessEndpointMVO(); + daeMVO.setUri(URI.create("https://test.com")); + daeMVO.setApiType("Test API type"); + daeMVO.setValue("Test value"); + daeMVO.setCategory("Test category"); + daeMVO.setDescription("Test description"); + daeMVO.setName("Test name"); + daeMVO.setEndOperatingDate(OffsetDateTime.now()); + daeMVO.setAdministrativeState(ResourceAdministrativeStateType.LOCKED); + daeMVO.setOperationalState(ResourceOperationalStateType.ENABLE); + daeMVO.setResourceStatus(ResourceStatusType.AVAILABLE); + daeMVO.setUsageState(ResourceUsageStateType.IDLE); + + DataFilterMapMVO dfmMVO = new DataFilterMapMVO(); + List<DataFilterMapItemMVO> mappings = new ArrayList<>(); + + DataFilterMapItemMVO dfmiMVO = new DataFilterMapItemMVO(); + + // Set filterTemplate value for dfmiMVO + DataFilterTemplateMVO dftMVO = new DataFilterTemplateMVO(); + dftMVO.setName("Test DataFilterTemplate"); + dftMVO.setDescription("A Test DataFilterTemplate"); + dfmiMVO.setFilterTemplate(dftMVO); + + // Set stringArray value for dfmiMVO + DataFilterAttributeStringArray dfasa = new DataFilterAttributeStringArray(); + List<String> list = new ArrayList<>(); + list.add("Test DataFilterAttributeString 1"); + list.add("Test DataFilterAttributeString 2"); + dfasa.setValue(list); + dfmiMVO.setStringArray(dfasa); + + mappings.add(dfmiMVO); + dfmMVO.setMappings(mappings); + daeMVO.setUriQueryFilter(dfmMVO); + daeList.add(daeMVO); + mcjMVO.setDataAccessEndpoint(daeList); + + MeasurementCollectionJob updatedMcj = measurementCollectionJobService.updateMeasurementCollectionJob(id, mcjMVO); + + assertThat(updatedMcj.getOutputFormat()).isEqualTo("Test Output Format"); + assertThat(updatedMcj.getGranularity()).isEqualTo(Granularity.G_5MN); + assertThat(updatedMcj.getReportingPeriod()).isEqualTo(ReportingPeriod.R_1H); + + List<DataAccessEndpoint> dataAccessEndpointList = updatedMcj.getDataAccessEndpoint(); + DataAccessEndpoint updatedDae = dataAccessEndpointList.get(0); + assertThat(updatedDae.getUri()).isEqualTo(URI.create("https://test.com")); + assertThat(updatedDae.getApiType()).isEqualTo("Test API type"); + assertThat(updatedDae.getValue()).isEqualTo("Test value"); + assertThat(updatedDae.getCategory()).isEqualTo("Test category"); + assertThat(updatedDae.getDescription()).isEqualTo("Test description"); + assertThat(updatedDae.getName()).isEqualTo("Test name"); + assertThat(updatedDae.getEndOperatingDate()).isEqualTo(daeMVO.getEndOperatingDate()); + assertThat(updatedDae.getAdministrativeState()).isEqualTo(ResourceAdministrativeStateType.LOCKED); + assertThat(updatedDae.getOperationalState()).isEqualTo(ResourceOperationalStateType.ENABLE); + assertThat(updatedDae.getResourceStatus()).isEqualTo(ResourceStatusType.AVAILABLE); + assertThat(updatedDae.getUsageState()).isEqualTo(ResourceUsageStateType.IDLE); + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testDeleteMeasurementCollectionJob() throws Exception { + MeasurementCollectionJob mcj = createMeasurementCollectionJob(); + String id = mcj.getUuid(); + + measurementCollectionJobService.deleteMeasurementCollectionJob(id); + + assertThat(measurementCollectionJobService.findAllMeasurementCollectionJobs().size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS); + } + + + + private MeasurementCollectionJob createMeasurementCollectionJob() throws Exception { + assertThat(measurementCollectionJobService.findAllMeasurementCollectionJobs().size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS); + + File fvo = new File("src/test/resources/testMeasurementCollectionJobFVO.json"); + InputStream in = new FileInputStream(fvo); + String mcjFVOText = IOUtils.toString(in, "UTF-8"); + + MeasurementCollectionJobFVO mcjFVO = JsonUtils.toJsonObj(mcjFVOText, MeasurementCollectionJobFVO.class); + + MeasurementCollectionJob response = measurementCollectionJobService.createMeasurementCollectionJob(mcjFVO); + + assertThat(measurementCollectionJobService.findAllMeasurementCollectionJobs().size()).isEqualTo(FIXED_BOOTSTRAPS_JOBS + 1); + + return response; + } +} diff --git a/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java b/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f196c06eb7da5cbd6493adf7dcde8c4692edee40 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java @@ -0,0 +1,455 @@ +package org.etsi.osl.services.api.po622; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.commons.io.IOUtils; +import org.etsi.osl.tmf.JsonUtils; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.pcm620.model.ProductOffering; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingRef; +import org.etsi.osl.tmf.pcm620.model.ProductSpecification; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationRef; +import org.etsi.osl.tmf.pcm620.reposervices.ProductCatalogRepoService; +import org.etsi.osl.tmf.pcm620.reposervices.ProductCategoryRepoService; +import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingPriceRepoService; +import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingRepoService; +import org.etsi.osl.tmf.pcm620.reposervices.ProductSpecificationRepoService; +import org.etsi.osl.tmf.po622.model.OrderItemActionType; +import org.etsi.osl.tmf.po622.model.ProductOrder; +import org.etsi.osl.tmf.po622.model.ProductOrderCreate; +import org.etsi.osl.tmf.po622.model.ProductOrderItem; +import org.etsi.osl.tmf.po622.model.ProductOrderItemStateType; +import org.etsi.osl.tmf.po622.model.ProductOrderStateType; +import org.etsi.osl.tmf.po622.model.ProductOrderUpdate; +import org.etsi.osl.tmf.po622.reposervices.ProductOrderRepoService; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; +import org.springframework.web.context.WebApplicationContext; +import jakarta.validation.Valid; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, + classes = OpenAPISpringBoot.class) +@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ProductOrderRepoServiceTest { + + @Autowired + private MockMvc mvc; + + @Autowired + ProductOrderRepoService productOrderRepoService; + + + @Autowired + ProductCatalogRepoService catalogRepoService; + + @Autowired + ProductCategoryRepoService categRepoService; + + @Autowired + ProductOfferingRepoService productOfferingRepoService; + + + @Autowired + ProductOfferingPriceRepoService productOfferingPriceRepoService; + + + @Autowired + ProductSpecificationRepoService productSpecificationRepoService; + + + @Autowired + private WebApplicationContext context; + + + + @Autowired + TransactionTemplate txTemplate; + + @Before + public void setup() throws Exception { + mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } + + + + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testFindAllParams() throws Exception { + + String response = createProductOrder(); + + ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); + String soId = responsesProductOrder.getId(); + String state = responsesProductOrder.getState().toString(); + + // Test with not null params + Map<String, String> params = new HashMap<>(); + params.put("state", state); + + List<ProductOrder> productOrderList = productOrderRepoService.findAllParams(params); + + boolean idExists = false; + for (ProductOrder po : productOrderList) { + if (po.getId().equals(soId)) { + idExists = true; + } + } + assertThat(idExists).isTrue(); + + // Test with null params + Map<String, String> paramsEmpty = new HashMap<>(); + List<ProductOrder> productOrderListEmptyParams = + productOrderRepoService.findAllParams(paramsEmpty); + + boolean idExistsEmptyParams = false; + for (ProductOrder so : productOrderListEmptyParams) { + if (so.getId().equals(soId)) { + idExistsEmptyParams = true; + } + } + assertThat(idExistsEmptyParams).isTrue(); + assertThat(productOrderListEmptyParams.size()) + .isEqualTo(productOrderRepoService.findAll().size()); + } + + + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testFindAllParamsJsonOrderIDs() throws Exception { + + String response = createProductOrder(); + String response2 = createProductOrder(); + + ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); + String soId = responsesProductOrder.getId(); + + ProductOrder responsesProductOrder2 = JsonUtils.toJsonObj(response2, ProductOrder.class); + String soId2 = responsesProductOrder2.getId(); + + String state = responsesProductOrder.getState().toString(); + Map<String, String> params = new HashMap<>(); + params.put("state", state); + + String soIds = productOrderRepoService.findAllParamsJsonOrderIDs(params); + assertThat(soIds).contains(soId); + assertThat(soIds).contains(soId2); + } + + + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testUpdateProductOrder() throws Exception { + + + assertThat(productOrderRepoService.findAll().size()).isEqualTo(0); + + String response = txTemplate.execute(status -> { + try { + return createProductOrder(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + }); + + + ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); + String poId = responsesProductOrder.getId(); + assertThat(productOrderRepoService.findAll().size()).isEqualTo(1); + + + + ProductOrder responseSOUpd = txTemplate.execute(status -> { + + ProductOrderUpdate prodOrderUpd = new ProductOrderUpdate(); + prodOrderUpd.setExpectedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + Note en = new Note(); + en.text("test note2"); + prodOrderUpd.addNoteItem(en); + + //ProductOrderItem its = responsesProductOrder.getProductOrderItem().stream().findFirst().get(); + ProductOrderItem its = new ProductOrderItem(); + prodOrderUpd.addProductOrderItemItem( its ); + + prodOrderUpd.getProductOrderItem().get(0).setState(ProductOrderItemStateType.INPROGRESS); + prodOrderUpd.setState(ProductOrderStateType.COMPLETED); + prodOrderUpd.setCategory("New Test Category"); + prodOrderUpd.setDescription("New Test Description"); + prodOrderUpd.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + prodOrderUpd.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + //return productOrderRepoService.updateProductOrder(poId, prodOrderUpd); + + byte[] req; + try { + req = JsonUtils.toJson(prodOrderUpd); + String responseP = mvc + .perform(MockMvcRequestBuilders.patch("/productOrderingManagement/v4/productOrder/" + poId) + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(req)) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + System.out.println(" ====================> " + responseP); + ProductOrder responsePO = JsonUtils.toJsonObj( responseP, ProductOrder.class); + return responsePO; + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + return null; + + + + }); + + int i = txTemplate.execute(status -> { + return productOrderRepoService.findAll().size(); + }); + + + assertThat(responseSOUpd.getState().toString()).isEqualTo("COMPLETED"); + assertThat(responseSOUpd.getDescription()).isEqualTo("New Test Description"); + + assertThat(productOrderRepoService.findAll().size()).isEqualTo(1); + + assertThat(responseSOUpd.getNote().size()).isEqualTo(3); + assertThat(responseSOUpd.getRelatedParty().size()).isEqualTo(1); + assertThat(responseSOUpd.getProductOrderItem().size()).isEqualTo(2); + + ProductOrderUpdate prodOrderUpd = new ProductOrderUpdate(); + Note en = new Note(); + en.text("test note3"); + prodOrderUpd.addNoteItem(en); + prodOrderUpd.addRelatedPartyItem(new RelatedParty()); + responseSOUpd = productOrderRepoService.updateProductOrder(poId, prodOrderUpd); + assertThat(productOrderRepoService.findAll().size()).isEqualTo(1); + assertThat(responseSOUpd.getNote().size()).isEqualTo(4); + assertThat(responseSOUpd.getRelatedParty().size()).isEqualTo(2); + + + } + + + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testGetProductOrderEagerAsString() throws Exception { + + String response = createProductOrder(); + ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); + String soId = responsesProductOrder.getId(); + + String eager = productOrderRepoService.getProductOrderEagerAsString(soId); + ProductOrder eagerProductOrder = JsonUtils.toJsonObj(eager, ProductOrder.class); + assertThat(eagerProductOrder.getDescription()).isEqualTo("A Test Product Order"); + assertThat(eagerProductOrder.getCategory()).isEqualTo("Test Category"); + assertThat(eagerProductOrder.getId()).isEqualTo(soId); + } + + + + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testGetImageProductOrderItemRelationshipGraph() throws Exception { + + String response = createProductOrder(); + ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); + String soId = responsesProductOrder.getId(); + Set<ProductOrderItem> productOrderItemSet = responsesProductOrder.getProductOrderItem(); + + for (ProductOrderItem soi : productOrderItemSet) { + String responseGraph = + productOrderRepoService.getImageProductOrderItemRelationshipGraph(soId, soi.getId()); + assertThat(responseGraph).isNotNull(); + } + } + + + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testCreateProductOfferingFromServiceSpec() throws Exception { + ServiceSpecification serviceSpec = createServiceSpecification(); + + String response = mvc + .perform(MockMvcRequestBuilders.post("/productCatalogManagement/v4/productOffering/fromServiceSpecId/" + serviceSpec.getId()) + .with(SecurityMockMvcRequestPostProcessors.csrf())) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + ProductOffering respOff = JsonUtils.toJsonObj(response, ProductOffering.class); + + assertThat(respOff).isNotNull(); + assertThat( respOff.getName() ).isEqualTo( "Test Spec2" ); + assertThat( respOff.getProductSpecification() ).isNotNull(); + assertThat( respOff.getProductSpecification().getName() ).isEqualTo( "Test Spec2" ); + + ProductSpecification prodSpec = productSpecificationRepoService.findByUuid( respOff.getProductSpecification().getId() ); + assertThat( prodSpec.getName() ).isEqualTo( "Test Spec2" ); + assertThat( prodSpec.getServiceSpecification().size() ).isEqualTo( 1 ); + assertThat( prodSpec.getProductSpecCharacteristic().size() ).isEqualTo( 2 ); + + assertThat( respOff.getProdSpecCharValueUse().size() ).isEqualTo( 2 ); + + + } + + + private String createProductOrder() throws Exception { + + int currSize = productOrderRepoService.findAll().size(); + + File sspec = new File("src/test/resources/testProductSpec.json"); + InputStream in = new FileInputStream(sspec); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ProductSpecificationCreate psc = + JsonUtils.toJsonObj(sspectext, ProductSpecificationCreate.class); + psc.setVersion("1.1"); + ProductSpecification responseProdSpec = createProductSpec(psc); + + + assertThat(productSpecificationRepoService.findAll().size()).isEqualTo(currSize + 1); + + + + ProductSpecificationRef prodSpecRef = new ProductSpecificationRef(); + prodSpecRef.setId(responseProdSpec.getId()); + @Valid + ProductOfferingCreate pefCre = new ProductOfferingCreate(); + pefCre.productSpecification(prodSpecRef); + + + ProductOffering pOffer = productOfferingRepoService.addProductOffering(pefCre); + + ProductOfferingRef prodOffRef = new ProductOfferingRef(); + prodOffRef.setId(pOffer.getId()); + + + + ProductOrderCreate productOrder = new ProductOrderCreate(); + productOrder.setCategory("Test Category"); + productOrder.setDescription("A Test Product Order"); + productOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + productOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + + + ProductOrderItem poi = new ProductOrderItem(); + poi.action(OrderItemActionType.ADD).productOffering(prodOffRef); + + productOrder.getProductOrderItem().add(poi); + + + byte[] req = JsonUtils.toJson(productOrder); + String response = mvc + .perform(MockMvcRequestBuilders.post("/productOrderingManagement/v4/productOrder") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(req)) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + + System.out.println(" ====================> " + response); + ProductOrder responsePO = JsonUtils.toJsonObj(response, ProductOrder.class); + + assertThat(productOrderRepoService.findAll().size()).isEqualTo(currSize + 1); + assertThat(responsePO.getId()).isNotNull(); + assertThat(responsePO.getCategory()).isEqualTo("Test Category"); + assertThat(responsePO.getDescription()).isEqualTo("A Test Product Order"); + assertThat(responsePO.getRelatedParty().size()).isEqualTo(1); + + assertThat(responsePO.getRelatedParty().stream().findFirst().get().getName()) + .isEqualTo("osadmin"); + + return response; + + } + + + private ProductSpecification createProductSpec(ProductSpecificationCreate prodSpecificationCreate) + throws Exception { + + String response = mvc + .perform(MockMvcRequestBuilders.post("/productCatalogManagement/v4/productSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(prodSpecificationCreate))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + ProductSpecification responsesSpec = JsonUtils.toJsonObj(response, ProductSpecification.class); + + return responsesSpec; + } + + private ServiceSpecification createServiceSpecification() throws Exception{ + + File sspec = new File( "src/test/resources/testServiceSpec2.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + ServiceSpecificationCreate serviceSpecificationCreate = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceSpecificationCreate ) )) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + assertThat( responsesSpec.getName() ).isEqualTo( "Test Spec2" ); + + + return responsesSpec; +} +} diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationApiControllerTest.java index 1aa8d1ad93d816b0a087ba4380fad137c9238490..5dc588e8c8c92eb90f8eaa88fe5e45fb9b03306d 100644 --- a/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationApiControllerTest.java @@ -222,7 +222,7 @@ public class ResourceSpecificationApiControllerTest { .andReturn().getResponse().getContentAsString(); List<LogicalResourceSpecification> listResSpecsResponse = JsonUtils.toListOfJsonObj(listResSpecsResponseString, LogicalResourceSpecification.class); - assertEquals(7, listResSpecsResponse.size()); + assertEquals(9, listResSpecsResponse.size()); mvc.perform(MockMvcRequestBuilders.get("/resourceCatalogManagement/v4/resourceSpecification") .contentType(MediaType.APPLICATION_JSON) diff --git a/src/test/java/org/etsi/osl/services/api/ri639/ResourceApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/ri639/ResourceApiControllerTest.java index 9e2f8df94245b1dd78af3745ecdfbd2efeb737e5..408ce1fb2038bdc1573345477dc0bc92c05d26d1 100644 --- a/src/test/java/org/etsi/osl/services/api/ri639/ResourceApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/ri639/ResourceApiControllerTest.java @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpStatus; @@ -48,6 +49,7 @@ import org.springframework.http.ResponseEntity; @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc +@AutoConfigureTestDatabase @ActiveProfiles("testing") public class ResourceApiControllerTest { diff --git a/src/test/java/org/etsi/osl/services/api/scm633/HubApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/HubApiControllerTest.java index 048ad19c20ee3c49ee427bf373885f4daa118d15..db51361f50c3dc04724dea3a43d21cdfd33304fa 100644 --- a/src/test/java/org/etsi/osl/services/api/scm633/HubApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/scm633/HubApiControllerTest.java @@ -17,6 +17,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -36,6 +37,7 @@ import org.springframework.web.context.WebApplicationContext; @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc @ActiveProfiles("testing") +@AutoConfigureTestDatabase //this automatically uses h2 public class HubApiControllerTest { @Autowired diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ServiceCandidateApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCandidateApiControllerTest.java index c8ed3f474d664be8bc421378cd331111f479c8b2..be25caffe40d26ac1f86ca3e09c9ebfa1026bccc 100644 --- a/src/test/java/org/etsi/osl/services/api/scm633/ServiceCandidateApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCandidateApiControllerTest.java @@ -25,6 +25,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -43,6 +44,7 @@ import org.springframework.web.context.WebApplicationContext; @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc +@AutoConfigureTestDatabase //this automatically uses h2 @ActiveProfiles("testing") public class ServiceCandidateApiControllerTest { diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ServiceCatalogApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCatalogApiControllerTest.java index 92b48d54028defe00acaa5f26c1f1f55f3f38219..65080e81409bd9ae8d8b6ad263ec0b4613a51484 100644 --- a/src/test/java/org/etsi/osl/services/api/scm633/ServiceCatalogApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCatalogApiControllerTest.java @@ -25,6 +25,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -43,6 +44,7 @@ import org.springframework.web.context.WebApplicationContext; @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc +@AutoConfigureTestDatabase //this automatically uses h2 @ActiveProfiles("testing") public class ServiceCatalogApiControllerTest { diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ServiceCategoryApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCategoryApiControllerTest.java index 865ca45fc3cb0b2f30ac468a7ea1fbbe92f92606..4163c54fc4a5df05824c25afcd094ababd8dc869 100644 --- a/src/test/java/org/etsi/osl/services/api/scm633/ServiceCategoryApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCategoryApiControllerTest.java @@ -16,6 +16,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -34,6 +35,7 @@ import org.springframework.web.context.WebApplicationContext; @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc +@AutoConfigureTestDatabase //this automatically uses h2 @ActiveProfiles("testing") public class ServiceCategoryApiControllerTest { diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java index e5aa51e2679c9804c6b0b34e2a7703b5a0d39abb..dea6f82aca386615db65e46c5d7e1b9e53550800 100644 --- a/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpHeaders; @@ -48,6 +49,7 @@ import org.springframework.web.context.WebApplicationContext; @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) @AutoConfigureMockMvc +@AutoConfigureTestDatabase @ActiveProfiles("testing") public class ServiceSpecificationApiControllerTest { diff --git a/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java index 7b6b52c8390833edec7a1462a0e3551444f03327..d433726a7f82478384f861b19c7d5644ce43283a 100644 --- a/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java @@ -40,7 +40,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.WebApplicationContext; - +import jakarta.validation.Valid; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; @@ -52,13 +52,18 @@ import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.is; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @RunWith(SpringRunner.class) @Transactional @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) -//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") //@TestPropertySource( @@ -69,6 +74,7 @@ public class ServiceRepoServiceTest { @Autowired ServiceRepoService serviceRepoService; + @Autowired ResourceRepoService resourceRepoService; @@ -102,6 +108,26 @@ public class ServiceRepoServiceTest { } assertThat( idExists ).isTrue(); } + + + @Test + public void testAddService() { + // When + ServiceCreate s = new ServiceCreate(); + s.setDescription("A Service for "); + s.setServiceDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + s.hasStarted(false); + s.setIsServiceEnabled(false); + s.setName("Servicename"); + s.setStartMode("0"); + + Service result = serviceRepoService.addService(s); + + // Then + assertNotNull(result); + assertEquals("Servicename", result.getName()); + + } // AlarmManagementIntegrationTest.testAlarmCreateAndUpdateRoutes:224 » CamelExecution Exception occurred during execution on the exchange: Exchange[0054D8F070E6449-0000000000000001] // PartyManagementIntegrationTest.addOrganization:246 » JDBCConnection Unable to acquire JDBC Connection [HikariPool-1 - Connection is not available, request timed out after 30000ms.] @@ -126,7 +152,10 @@ public class ServiceRepoServiceTest { @Test public void testDeleteServiceActionQueueItemByUuid() throws Exception { ServiceActionQueueItem saqi = new ServiceActionQueueItem(); - ServiceActionQueueItem saqiResponse = serviceRepoService.addServiceActionQueueItem(saqi); + String response = createService(); + Service aservice = JsonUtils.toJsonObj(response, Service.class); + + ServiceActionQueueItem saqiResponse = serviceRepoService.addServiceActionQueueItem(aservice, saqi); String uuid = saqiResponse.getUuid(); serviceRepoService.deleteServiceActionQueueItemByUuid(uuid); @@ -230,42 +259,118 @@ public class ServiceRepoServiceTest { // // org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection [HikariPool-1 - Connection is not available, request timed out after 30000ms.] -// @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) -// @Test -// public void testResourceStateChangedEvent() throws Exception { -// String response = createService(); -// Service responsesService = JsonUtils.toJsonObj(response, Service.class); -// String id = responsesService.getId(); -// Set<ResourceRef> resourceRefSet = responsesService.getSupportingResource(); -// List<ResourceRef> resourceRefList = new ArrayList<>(resourceRefSet); -// -// assertThat(resourceRefList.size()).isEqualTo(1); -// ResourceRef firstResourceRef = resourceRefList.get(0); -// -// Resource resource = resourceRepoService.findByUuid(firstResourceRef.getId()); -// -// ResourceStateChangeNotification resourceCreateNotification = new ResourceStateChangeNotification(); -// ResourceStateChangeEvent event = new ResourceStateChangeEvent(); -// event.getEvent().setResource(resource); -// resourceCreateNotification.setEvent(event); -// -// serviceRepoService.resourceStateChangedEvent(resourceCreateNotification); -// Service updatedService = serviceRepoService.findByUuid(id); -// -// Set<Note> noteSet = updatedService.getNote(); -// List<Note> noteList = new ArrayList<>(noteSet); -// -// boolean expectedNoteExists = false; -// for (Note n : noteList) { -// if ( n.getText().contains("State Changed with status:") && n.getAuthor().equals("SIM638-API")) { -// expectedNoteExists= true; -// break; -// } -// } -// assertThat( expectedNoteExists ).isTrue(); -// } + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testResourceStateChangedEvent() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + Set<ResourceRef> resourceRefSet = responsesService.getSupportingResource(); + List<ResourceRef> resourceRefList = new ArrayList<>(resourceRefSet); + + assertThat(resourceRefList.size()).isEqualTo(1); + ResourceRef firstResourceRef = resourceRefList.get(0); + + Resource resource = resourceRepoService.findByUuid(firstResourceRef.getId()); + resource.setResourceStatus(ResourceStatusType.STANDBY); + + ResourceStateChangeNotification resourceCreateNotification = new ResourceStateChangeNotification(); + ResourceStateChangeEvent event = new ResourceStateChangeEvent(); + event.getEvent().setResource(resource); + resourceCreateNotification.setEvent(event); + + serviceRepoService.resourceStateChangedEvent(resourceCreateNotification); + Service updatedService = serviceRepoService.findByUuid(id); + Set<Note> noteSet = updatedService.getNote(); + List<Note> noteList = new ArrayList<>(noteSet); + boolean expectedNoteExists = false; + for (Note n : noteList) { + if ( n.getText().contains("Supporting Resource changed with") && n.getAuthor().equals("SIM638-API")) { + expectedNoteExists= true; + break; + } + } + assertThat( expectedNoteExists ).isTrue(); + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testResourceAttrChangedEvent() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + Set<ResourceRef> resourceRefSet = responsesService.getSupportingResource(); + List<ResourceRef> resourceRefList = new ArrayList<>(resourceRefSet); + + assertThat(resourceRefList.size()).isEqualTo(1); + ResourceRef firstResourceRef = resourceRefList.get(0); + + Resource resource = resourceRepoService.findByUuid(firstResourceRef.getId()); + assertThat( resource.getResourceCharacteristic().size() ).isEqualTo( 0 ); + + + + + + Service updatedService = serviceRepoService.findByUuid(id); + + assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 7 ); + assertThat( updatedService.getSupportingResource().size() ).isEqualTo( 1); + + + assertThat( updatedService.getServiceCharacteristicByName("NSLCM").getValue().getValue() ).isEqualTo( "nslcm_test" ); + + ResourceUpdate resourceUpdate = new ResourceUpdate(); + + + + org.etsi.osl.tmf.ri639.model.Characteristic resCharacteristicItem = new org.etsi.osl.tmf.ri639.model.Characteristic(); + + resCharacteristicItem.setName( "NSLCM" ); + resCharacteristicItem.setValue( new Any("nslcm_test2")); + resourceUpdate.addResourceCharacteristicItem(resCharacteristicItem); + + resCharacteristicItem = new org.etsi.osl.tmf.ri639.model.Characteristic(); + resCharacteristicItem.setName( "newChar" ); + resCharacteristicItem.setValue( new Any("myval0")); + resourceUpdate.addResourceCharacteristicItem(resCharacteristicItem); + + + System.out.println("STEP 1 - =========================================== " +serviceRepoService.toString() ); + Resource nullResource = resourceRepoService.updateResource( resource.getId(), resourceUpdate, false); + resource = resourceRepoService.findByUuid(firstResourceRef.getId()); + nullResource.setResourceStatus(ResourceStatusType.AVAILABLE); + assertThat( resource.getResourceCharacteristic().size() ).isEqualTo( 2 ); + + Thread.sleep(1000); + + System.out.println("STEP 3 - =========================================== " ); + + serviceRepoService.updateServicesHavingThisSupportingResource(nullResource); + + updatedService = serviceRepoService.findByUuid(id); + assertThat( updatedService.getSupportingResource().size() ).isEqualTo( 1); + assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 8 ); + + + Set<Note> noteSet = updatedService.getNote(); + List<Note> noteList = new ArrayList<>(noteSet); + + boolean expectedNoteExists = false; + for (Note n : noteList) { + if ( n.getText().contains("Supporting Resource changed with") && n.getAuthor().equals("SIM638-API")) { + expectedNoteExists= true; + break; + } + } + assertThat( expectedNoteExists ).isTrue(); + } + + + + @Transactional private String createService() throws Exception { int servicesCount = serviceRepoService.findAll().size(); @@ -336,6 +441,12 @@ public class ServiceRepoServiceTest { serviceCharacteristicItem.setName( "long_string" ); serviceCharacteristicItem.setValue( new Any("12345")); aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "_DETAILED_NOTES_" ); + serviceCharacteristicItem.setValue( new Any("_DETAILED_NOTES_")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); aServiceSpecificationRef.setId(responsesSpec3.getId() ); @@ -384,6 +495,44 @@ public class ServiceRepoServiceTest { return response; } + @Test + public void testFindNextStateBasedOnSupportingResources() throws Exception { + Service s = new Service(); + s.setState(ServiceStateType.RESERVED); + List<Resource> rlist = new ArrayList<Resource>(); + Resource r1 = new Resource(); + Resource r2 = new Resource(); + r1.setResourceStatus(ResourceStatusType.RESERVED); + r2.setResourceStatus(ResourceStatusType.RESERVED); + rlist.add(r1); + rlist.add(r2); + ServiceStateType nstate = s.findNextStateBasedOnResourceList(rlist); + assertThat(nstate).isEqualTo( ServiceStateType.RESERVED ); + + r1.setResourceStatus(ResourceStatusType.AVAILABLE); + nstate = s.findNextStateBasedOnResourceList(rlist); + assertThat(nstate).isEqualTo( ServiceStateType.RESERVED ); + + r2.setResourceStatus(ResourceStatusType.AVAILABLE); + nstate = s.findNextStateBasedOnResourceList(rlist); + assertThat(nstate).isEqualTo( ServiceStateType.ACTIVE ); + + s.setState( ServiceStateType.ACTIVE ); + r1.setResourceStatus(ResourceStatusType.UNKNOWN); + nstate = s.findNextStateBasedOnResourceList(rlist); + assertThat(nstate).isEqualTo( ServiceStateType.ACTIVE ); + + r1.setResourceStatus(ResourceStatusType.SUSPENDED); + nstate = s.findNextStateBasedOnResourceList(rlist); + assertThat(nstate).isEqualTo( ServiceStateType.TERMINATED ); + + s.setState( ServiceStateType.TERMINATED ); + r1.setResourceStatus(ResourceStatusType.AVAILABLE); + nstate = s.findNextStateBasedOnResourceList(rlist); + assertThat(nstate).isEqualTo( ServiceStateType.TERMINATED ); + + + } private ServiceSpecification createServiceSpec(String sspectext, ServiceSpecificationCreate sspeccr1) throws Exception{ String response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") diff --git a/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderApiControllerTest.java index 305d454c0c3391b3f454e05b56e7a0d72d6e45b0..ac1dad1cfe692094e836921057e074dba76fceb0 100644 --- a/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderApiControllerTest.java @@ -31,6 +31,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -50,7 +51,7 @@ import org.springframework.web.context.WebApplicationContext; webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class ) -//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") public class ServiceOrderApiControllerTest { diff --git a/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java b/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java index 2cc5b0e9f819bc1a94867eeeca9afb03773014bf..dc3a7c1e1367410141b4f0c1f78d571ab30b4618 100644 --- a/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java @@ -26,6 +26,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -45,7 +46,7 @@ import org.springframework.web.context.WebApplicationContext; webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class ) -//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") public class ServiceOrderRepoServiceTest { diff --git a/src/test/java/org/etsi/osl/services/reposervices/ri639/ResourceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/reposervices/ri639/ResourceRepoServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..84fe0e893ef157cbc9f21f522809f9f0a0122b4b --- /dev/null +++ b/src/test/java/org/etsi/osl/services/reposervices/ri639/ResourceRepoServiceTest.java @@ -0,0 +1,322 @@ +package org.etsi.osl.services.reposervices.ri639; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceStatusType; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; +import org.etsi.osl.tmf.ri639.model.ResourceUsageStateType; +import org.etsi.osl.tmf.ri639.repo.ResourceRepository; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Unit tests for {@link resourceRepoService}. + * + * This class uses Mockito and Spring's testing framework to mock dependencies + * and verify the behavior of the resourceRepoService. + */ +@RunWith(SpringRunner.class) +@ActiveProfiles("testing") +@SpringBootTest(classes = OpenAPISpringBoot.class) +public class ResourceRepoServiceTest { + /** + * The service being tested, with a spy to allow partial mocking of certain methods. + */ + @SpyBean + @Autowired + private ResourceRepoService resourceRepoService; + + /** + * Mock for the {@link resourceRepository} to simulate repository operations. + */ + @MockBean + private ResourceRepository resourceRepo; + + private static ResourceCreate resourceCreate; + + private static Resource resource; + + /** + * Loads test data from JSON files before all tests. + * + * @throws Exception if there is an error loading the test data. + */ + @BeforeClass + public static void setupBeforeClass() { + // Load resourceCreate and resourceUpdare from the + // JSON files into the respective classes + try { + ObjectMapper mapper = new ObjectMapper(); + + // Configure the mapper to ignore unknown fields that are present in + // the JSON but not in the class. This is needed to be able to + // update a resource using a Resource or a ResourceUpdate. + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + resourceCreate = mapper.readValue( + new File( + "src/test/resources/reposervices/ram702/resourceCreate.json" + ), + ResourceCreate.class + ); + + resource = mapper.readValue( + new File( + "src/test/resources/reposervices/ram702/resource.json" + ), + Resource.class + ); + + } catch (Exception ex) { + ex.printStackTrace(); + } + + // Assert that the files were properly loaded + assertNotNull(resourceCreate); + assertNotNull(resource); + } + + /** + * Sets up common mock behavior for the repository before each test. + * @throws ResourceNotFoundException + */ + @Before + public void setupBefore() { + when(resourceRepo.findByUuid(anyString())).thenReturn(Optional.of(resource)); + when(resourceRepo.save(any(Resource.class))).thenReturn(resource); + when(resourceRepo.saveAndFlush(any(Resource.class))).thenReturn(resource); + doReturn(resource).when(resourceRepoService).getResourceEager(anyString()); + } + + /** + * Test for {@link resourceRepoService#findByUuid(String)} when a resource is found. + * + * @throws ResourceNotFoundException if the resource is not found (not expected). + */ + @Test + public void testFindByUuidWhenResourceIsFound() { + // When + Resource result = resourceRepoService.findByUuid(anyString()); + + // Then + assertNotNull(result); + verify(resourceRepo, times(1)).findByUuid(anyString()); + } + + /** + * Test for {@link resourceRepoService#findAll()} to verify it retrieves all resources. + */ + @Test + public void testFindAllResources() { + // Given + List<Resource> resources = new ArrayList<>(); + Resource resource1 = new Resource(); + resource1.setName("resource1"); + Resource resource2 = new Resource(); + resource2.setName("resource2"); + resources.add(resource1); + resources.add(resource2); + + // Mock repository to return the list of resources + when(resourceRepo.findAll()).thenReturn(resources); + + // When + List<Resource> result = resourceRepoService.findAll(); + + // Then + assertNotNull(result); + assertEquals(2, result.size()); + assertEquals("resource1", result.get(0).getName()); + assertEquals("resource2", result.get(1).getName()); + verify(resourceRepo, times(1)).findAll(); + } + + /** + * Test for {@link resourceRepoService#addResource(ResourceCreate)} to verify resource creation. + */ + @Test + public void testAddResource() { + // When + Resource result = resourceRepoService.addResource(resourceCreate); + + // Then + assertNotNull(result); + assertEquals("test_resource", result.getName()); + verify(resourceRepo, times(1)).saveAndFlush(any(Resource.class)); + } + + /** + * Test for {@link resourceRepoService#updateResource(String, ResourceUpdate, boolean)} + * to verify resource update when the resource is found. + * + * @throws ResourceNotFoundException if the resource is not found (not expected). + */ + @Test + public void testUpdateResourceWhenResourceIsFound(){ + ResourceUpdate update = new ResourceUpdate(); + update.setName("updated_name"); + update.setCategory("updated_category"); + update.setDescription("Updated description"); + update.setStartOperatingDate(OffsetDateTime.now()); + update.setEndOperatingDate(OffsetDateTime.now().plusDays(1)); + update.setUsageState(ResourceUsageStateType.ACTIVE); + update.setResourceStatus(ResourceStatusType.AVAILABLE); + update.setResourceVersion("2.0"); + + // When + Resource updatedResource = resourceRepoService.updateResource("123", update, false); + + // Then + assertNotNull(updatedResource); + assertEquals("updated_name", updatedResource.getName()); + assertEquals("updated_name", updatedResource.getName()); + assertEquals("updated_category", updatedResource.getCategory()); + assertEquals("Updated description", updatedResource.getDescription()); + assertNotNull(updatedResource.getStartOperatingDate()); + assertNotNull(updatedResource.getEndOperatingDate()); + assertEquals(ResourceUsageStateType.ACTIVE, updatedResource.getUsageState()); + assertEquals(ResourceStatusType.AVAILABLE, updatedResource.getResourceStatus()); + assertEquals("2.0", updatedResource.getResourceVersion()); + + verify(resourceRepo, times(1)).saveAndFlush(any(Resource.class)); + } + + /** + * Test for {@link resourceRepoService#deleteByUuid(String)} to verify successful resource deletion. + * + * @throws ApiException if there is an error during the deletion process (not expected). + */ + @Test + public void testDeleteByUuidWhenResourceIsFound() { + // When + resourceRepoService.deleteByUuid("123"); + + // Then + verify(resourceRepo, times(1)).delete(resource); + } + + /** + * Test for {@link resourceRepoService#addOrUpdateResourceByNameCategoryVersion(String, String, String, ResourceCreate)} + * when an existing resource is found and updated. + * + * @throws ApiException if there is an error during the update process. + */ + @Test + public void testAddOrUpdateResourceByNameCategoryVersionWhenResourceExists() { + // Given + ResourceUpdate update = new ResourceUpdate(); + update.setName("updated_name"); + + String name = "test_resource"; + String category = "Category 1"; + String version = "1.0"; + + List<Resource> existingResources = Collections.singletonList(resource); + + // Mock the repository to return the existing resource + when(resourceRepo.findByNameAndCategoryAndResourceVersion(anyString(), anyString(), anyString())) + .thenReturn(existingResources); + + // Mock the updateResource method to return the updated resource + when(resourceRepoService.updateResource("123", update, false)) + .thenReturn(resource); + + // When + Resource result = resourceRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); + + // Then + assertNotNull(result); + assertEquals("test_resource", result.getName()); + verify(resourceRepoService, times(1)).updateResource("123", update, false); + } + + /** + * Test for {@link resourceRepoService#addOrUpdateResourceByNameCategoryVersion(String, String, String, ResourceCreate)} + * when no existing resource is found, and a new one is created. + * + * @throws ApiException if there is an error during the creation process. + */ + @Test + public void testAddOrUpdateResourceByNameCategoryVersionWhenResourceDoesNotExist(){ + // Given + String name = "test_resource"; + String category = "Category 1"; + String version = "1.0"; + + // Mock an empty list of existing resources + List<Resource> noResources = new ArrayList<>(); + + // Mock the repository to return no existing resources + when(resourceRepo.findByNameAndCategoryAndResourceVersion(anyString(), anyString(), anyString())) + .thenReturn(noResources); + + // Mock the addResource method to return the newly created resource + when(resourceRepoService.addResource(resourceCreate)).thenReturn(resource); + + // When + Resource result = resourceRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); + + // Then + assertNotNull(result); + assertEquals("test_resource", result.getName()); + verify(resourceRepoService, times(1)).addResource(any(ResourceCreate.class)); + verify(resourceRepoService, never()).updateResource(result.getId(), resourceCreate, false); + } + + /** + * Test for {@link resourceRepoService#raiseResourceAttributeValueChangeEventNotification(Resource)} + * to ensure a resource attribute value change notification is published. + */ + @Test + public void testFindAllActiveResourcesToTerminate() { + // Given + List<Resource> resources = new ArrayList<>(); + Resource resource1 = mock(Resource.class); + when(resource1.getId()).thenReturn("uuid1"); + resources.add(resource1); + + when(resourceRepo.findActiveToTerminate()).thenReturn(resources); + + // When + List<String> result = resourceRepoService.findAllActiveResourcesToTerminate(); + + // Then + assertNotNull(result); + assertEquals(1, result.size()); + assertEquals("uuid1", result.get(0)); + verify(resourceRepo, times(1)).findActiveToTerminate(); + } +} diff --git a/src/test/java/org/etsi/osl/services/reposervices/scm633/ServiceSpecificationRepoServiceTest.java b/src/test/java/org/etsi/osl/services/reposervices/scm633/ServiceSpecificationRepoServiceTest.java index c5e308251e6bfdef4a532431393d966cc46d86fa..8033d6cb3ec915a6a75f5b0eb2a69ed436b61d50 100644 --- a/src/test/java/org/etsi/osl/services/reposervices/scm633/ServiceSpecificationRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/reposervices/scm633/ServiceSpecificationRepoServiceTest.java @@ -37,18 +37,23 @@ import org.mockito.Mock; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.validation.Valid; @RunWith(SpringRunner.class) @ActiveProfiles("testing") -@SpringBootTest(classes = OpenAPISpringBoot.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@AutoConfigureTestDatabase public class ServiceSpecificationRepoServiceTest { @Autowired diff --git a/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/service/ServiceNSLCMRepoServiceTest.java similarity index 80% rename from src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java rename to src/test/java/org/etsi/osl/services/service/ServiceNSLCMRepoServiceTest.java index 255b054f7abdb1b13d889e96d21ec5f3dce897ea..29ea3bde1c624ee38a98240ce67fc30710ce83cc 100644 --- a/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/service/ServiceNSLCMRepoServiceTest.java @@ -37,18 +37,25 @@ import org.mockito.Mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; @RunWith(SpringRunner.class) +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) +@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureMockMvc @ActiveProfiles("testing") -@SpringBootTest(classes = OpenAPISpringBoot.class) -//@DataJpaTest -public class ServiceRepoServiceTest { +public class ServiceNSLCMRepoServiceTest { @Mock private ServiceRepository serviceRepository; @@ -174,7 +181,22 @@ public class ServiceRepoServiceTest { serviceRepoService.updateNSLCMCharacteristic(service, n); - assertEquals("[\"null\"]", service.getServiceCharacteristicByName(n.getName()).getValue().getValue()); + try { + ArrayNode expected = (ArrayNode) objectMapper.readTree( + "[]" + ); + ArrayNode actual = (ArrayNode) objectMapper.readTree( + service.getServiceCharacteristicByName(n.getName()).getValue().getValue() + ); + + assertEquals( + expected, + actual + ); + break; + } catch (JsonProcessingException e) { + e.printStackTrace(); + } } } } @@ -211,10 +233,22 @@ public class ServiceRepoServiceTest { serviceRepoService.updateNSLCMCharacteristic(service, n); - assertEquals( - "[\"{\\\"queuePosition\\\":0,\\\"lcmOperationType\\\":\\\"instantiate\\\",\\\"detailed-status\\\":\\\"Done\\\",\\\"operationState\\\":\\\"COMPLETED\\\",\\\"errorMessage\\\":null,\\\"nsInstanceId\\\":\\\"420fa806-f2f8-405e-8348-11e4fcd13f25\\\",\\\"_admin\\\":{\\\"projects_write\\\":[\\\"92636b50-d607-4801-98b5-f0da541363be\\\"],\\\"created\\\":1.7169792184842422E9,\\\"modified\\\":1.7169794444025614E9,\\\"worker\\\":\\\"d6f95b754d12\\\",\\\"projects_read\\\":[\\\"92636b50-d607-4801-98b5-f0da541363be\\\"]},\\\"detailedStatus\\\":null,\\\"stage\\\":\\\"\\\",\\\"operationParams\\\":{\\\"nsInstanceId\\\":\\\"420fa806-f2f8-405e-8348-11e4fcd13f25\\\",\\\"ssh_keys\\\":[\\\"\\\"],\\\"lcmOperationType\\\":\\\"instantiate\\\",\\\"nsdId\\\":\\\"338d3a8c-af70-446a-af37-ed8bb97a6641\\\",\\\"nsName\\\":\\\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\\\",\\\"vimAccountId\\\":\\\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\\\"},\\\"startTime\\\":1.7169792184841862E9,\\\"links\\\":{\\\"nsInstance\\\":\\\"/osm/nslcm/v1/ns_instances/420fa806-f2f8-405e-8348-11e4fcd13f25\\\",\\\"self\\\":\\\"/osm/nslcm/v1/ns_lcm_op_occs/e0836187-7d4a-49ac-a317-fc4108ed2f93\\\"},\\\"_id\\\":\\\"e0836187-7d4a-49ac-a317-fc4108ed2f93\\\",\\\"id\\\":\\\"e0836187-7d4a-49ac-a317-fc4108ed2f93\\\",\\\"isAutomaticInvocation\\\":false,\\\"isCancelPending\\\":false,\\\"statusEnteredTime\\\":1.7169794444025595E9}\"]", + try { + ArrayNode expected = (ArrayNode) objectMapper.readTree( + "[{\"queuePosition\":0,\"lcmOperationType\":\"instantiate\",\"detailed-status\":\"Done\",\"operationState\":\"COMPLETED\",\"errorMessage\":null,\"nsInstanceId\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"_admin\":{\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169792184842422E9,\"modified\":1.7169794444025614E9,\"worker\":\"d6f95b754d12\",\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"]},\"detailedStatus\":null,\"stage\":\"\",\"operationParams\":{\"nsInstanceId\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"ssh_keys\":[\"\"],\"lcmOperationType\":\"instantiate\",\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"nsName\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"},\"startTime\":1.7169792184841862E9,\"links\":{\"nsInstance\":\"/osm/nslcm/v1/ns_instances/420fa806-f2f8-405e-8348-11e4fcd13f25\",\"self\":\"/osm/nslcm/v1/ns_lcm_op_occs/e0836187-7d4a-49ac-a317-fc4108ed2f93\"},\"_id\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"id\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"isAutomaticInvocation\":false,\"isCancelPending\":false,\"statusEnteredTime\":1.7169794444025595E9}]" + ); + ArrayNode actual = (ArrayNode) objectMapper.readTree( service.getServiceCharacteristicByName(n.getName()).getValue().getValue() - ); + ); + + assertEquals( + expected, + actual + ); + break; + } catch (JsonProcessingException e) { + e.printStackTrace(); + } } } } @@ -247,15 +281,27 @@ public class ServiceRepoServiceTest { // Check if the name contains "NSLCM" in any case if (n.getName().toUpperCase().contains("NSLCM")) { - // Set the value of NSLCM to null - service.getServiceCharacteristicByName(n.getName()).getValue().setValue("[\"existingValue\"]"); + // Set the value of NSLCM + service.getServiceCharacteristicByName(n.getName()).getValue().setValue("[{\"test\": 2}]"); serviceRepoService.updateNSLCMCharacteristic(service, n); - assertEquals( - "[\"existingValue\",\"{\\\"queuePosition\\\":0,\\\"lcmOperationType\\\":\\\"instantiate\\\",\\\"detailed-status\\\":\\\"Done\\\",\\\"operationState\\\":\\\"COMPLETED\\\",\\\"errorMessage\\\":null,\\\"nsInstanceId\\\":\\\"420fa806-f2f8-405e-8348-11e4fcd13f25\\\",\\\"_admin\\\":{\\\"projects_write\\\":[\\\"92636b50-d607-4801-98b5-f0da541363be\\\"],\\\"created\\\":1.7169792184842422E9,\\\"modified\\\":1.7169794444025614E9,\\\"worker\\\":\\\"d6f95b754d12\\\",\\\"projects_read\\\":[\\\"92636b50-d607-4801-98b5-f0da541363be\\\"]},\\\"detailedStatus\\\":null,\\\"stage\\\":\\\"\\\",\\\"operationParams\\\":{\\\"nsInstanceId\\\":\\\"420fa806-f2f8-405e-8348-11e4fcd13f25\\\",\\\"ssh_keys\\\":[\\\"\\\"],\\\"lcmOperationType\\\":\\\"instantiate\\\",\\\"nsdId\\\":\\\"338d3a8c-af70-446a-af37-ed8bb97a6641\\\",\\\"nsName\\\":\\\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\\\",\\\"vimAccountId\\\":\\\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\\\"},\\\"startTime\\\":1.7169792184841862E9,\\\"links\\\":{\\\"nsInstance\\\":\\\"/osm/nslcm/v1/ns_instances/420fa806-f2f8-405e-8348-11e4fcd13f25\\\",\\\"self\\\":\\\"/osm/nslcm/v1/ns_lcm_op_occs/e0836187-7d4a-49ac-a317-fc4108ed2f93\\\"},\\\"_id\\\":\\\"e0836187-7d4a-49ac-a317-fc4108ed2f93\\\",\\\"id\\\":\\\"e0836187-7d4a-49ac-a317-fc4108ed2f93\\\",\\\"isAutomaticInvocation\\\":false,\\\"isCancelPending\\\":false,\\\"statusEnteredTime\\\":1.7169794444025595E9}\"]", + try { + ArrayNode expected = (ArrayNode) objectMapper.readTree( + "[{\"test\": 2}, {\"queuePosition\":0,\"lcmOperationType\":\"instantiate\",\"detailed-status\":\"Done\",\"operationState\":\"COMPLETED\",\"errorMessage\":null,\"nsInstanceId\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"_admin\":{\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169792184842422E9,\"modified\":1.7169794444025614E9,\"worker\":\"d6f95b754d12\",\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"]},\"detailedStatus\":null,\"stage\":\"\",\"operationParams\":{\"nsInstanceId\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"ssh_keys\":[\"\"],\"lcmOperationType\":\"instantiate\",\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"nsName\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"},\"startTime\":1.7169792184841862E9,\"links\":{\"nsInstance\":\"/osm/nslcm/v1/ns_instances/420fa806-f2f8-405e-8348-11e4fcd13f25\",\"self\":\"/osm/nslcm/v1/ns_lcm_op_occs/e0836187-7d4a-49ac-a317-fc4108ed2f93\"},\"_id\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"id\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"isAutomaticInvocation\":false,\"isCancelPending\":false,\"statusEnteredTime\":1.7169794444025595E9}]" + ); + ArrayNode actual = (ArrayNode) objectMapper.readTree( service.getServiceCharacteristicByName(n.getName()).getValue().getValue() - ); + ); + + assertEquals( + expected, + actual + ); + break; + } catch (JsonProcessingException e) { + e.printStackTrace(); + } } } } diff --git a/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json index eaf940892bbb3fcc1befe9fbd52bcfefe49e53ae..156e771fe4421b8ce41954da4f6e0f5efc909796 100644 --- a/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json +++ b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json @@ -1 +1,616 @@ -{"uuid":"910146b3-67e9-4d8f-8141-066c6ca7ab60","endDate":"2024-05-30T10:39:42.142Z","startDate":"2024-05-29T10:40:07.811452Z","description":"A Service for tutorial_ns@osm14","@baseType":"BaseRootNamedEntity","@schemaLocation":null,"@type":"ResourceFacingService","href":null,"name":"tutorial_ns@osm14","id":"910146b3-67e9-4d8f-8141-066c6ca7ab60","category":"ResourceFacingService","hasStarted":false,"isServiceEnabled":false,"isStateful":null,"serviceDate":"2024-05-29T10:40:07.811412476Z","serviceType":"tutorial_ns@osm14","startMode":"AUTOMATICALLY_MANAGED","note":[{"uuid":"b5176ca9-a909-4baf-8d42-788296bdb0b0","date":"2024-05-29T10:43:26.422075Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"c58afe4b-d265-4c7a-a4fc-c059ccfcd852","date":"2024-05-29T10:42:46.354267Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"d6385fda-e220-4e82-ae86-9a0eab68ca97","date":"2024-05-29T10:43:06.526422Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"e5eb63a2-0660-4027-bb77-3d5d946854e2","date":"2024-05-29T10:40:08.018182Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service reserved"},{"uuid":"a24a4c0d-91fa-4ac9-b6e0-66d1c9e77fb8","date":"2024-05-29T10:40:46.703148Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"76c96e75-a805-4e02-ba36-d0a968fdb772","date":"2024-05-29T10:40:10.329551Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: DeploymentRequestID, Status, OperationalStatus, ConstituentVnfrIps, ConfigStatus, APPLY_CONFIG, InstanceId, NSR, NSLCM, "},{"uuid":"b3c6665c-1ade-465f-abf5-d530d42f9e71","date":"2024-05-29T10:42:26.406336Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, NSR, "},{"uuid":"cd9ead3c-bb20-4032-b451-e79971a179d2","date":"2024-05-29T10:41:26.256050Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, NSR, OperationalStatus, ConfigStatus, "},{"uuid":"d46922a2-96a6-4177-b85d-14ecd5b0e335","date":"2024-05-29T10:42:06.544071Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"196621c2-e45b-4c9b-8cef-3386757a565d","date":"2024-05-29T10:42:06.389619Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"065341af-6dc1-4b9e-b9f5-026c4da1866f","date":"2024-05-29T10:40:10.262832Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"openslice-osom","system":null,"text":"Request to NFVO osm14 with Deployment Request id:4"},{"uuid":"54465e59-e976-410f-971e-c82fead34c87","date":"2024-05-29T10:43:26.320461Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, NSR, "},{"uuid":"58d14daf-106f-4cfa-98f0-ab9215729cb1","date":"2024-05-29T10:44:06.331840Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"7ea7a9fc-c04a-46bc-908f-0c6e9a9b3d5c","date":"2024-05-29T10:40:08.006718Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"openslice-osom","system":null,"text":"Service Created by CreateReservedService"},{"uuid":"73fa711b-6fc9-4933-b836-353464229ce5","date":"2024-05-29T10:41:06.420721Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"54e36f92-12e3-40d4-847d-1290980ce831","date":"2024-05-29T10:40:26.497483Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, InstanceId, Status, "},{"uuid":"c1fbfdbb-5efd-47e3-ba82-d04859398660","date":"2024-05-29T10:40:10.772955Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"7f6b5dbc-38c4-4524-ba36-3801a070c46b","date":"2024-05-29T10:44:06.448514Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"3f6bbca6-a582-4269-81f2-f32da6d7ce58","date":"2024-05-29T10:42:46.444646Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"ded38a15-5fdf-4b83-af6a-26e835a9dc5a","date":"2024-05-29T10:43:46.366950Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"9f05ea6b-f390-4666-8feb-7dc7e73f4899","date":"2024-05-29T10:40:46.361042Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"33abb807-0418-4f0a-b7ef-57b8c6e40e45","date":"2024-05-29T10:41:26.377603Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "},{"uuid":"559f81ff-0178-47f1-9e9d-34efef76f48b","date":"2024-05-29T10:41:46.362854Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, "}],"place":[],"relatedParty":[],"serviceCharacteristic":[{"uuid":"0126b0b1-96ea-4490-9302-6a61cf7567a7","value":{"value":"338d3a8c-af70-446a-af37-ed8bb97a6641","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OSM_NSDCATALOGID","valueType":"TEXT"},{"uuid":"ef5df2c3-ff08-43aa-aa28-9b03b3ac72b9","value":{"value":"1","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"MANOproviderID","valueType":"TEXT"},{"uuid":"df7a9636-2897-4ba3-a533-ad3ffe37df2d","value":{"value":"2","alias":"id"},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"NSDID","valueType":"TEXT"},{"uuid":"fc1987da-497d-47c3-8f03-6c3bf6f10716","value":{"value":"osm14","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"MANOproviderName","valueType":"TEXT"},{"uuid":"9ab40cb6-05e5-4ad3-aeed-e29870de6011","value":{"value":"f6f1ad7f-b312-4ba0-8f21-de1d42cb2451","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OnBoardDescriptorUUID","valueType":"TEXT"},{"uuid":"58bc2253-0392-4543-8f28-14c1052feb2f","value":{"value":"2","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OnBoardDescriptorID","valueType":"TEXT"},{"uuid":"927823e7-e6fc-4836-97f0-db5d89b29cde","value":{"value":"","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"SSHKEY","valueType":"TEXT"},{"uuid":"e3d3d14c-cc84-47e0-9688-cffe8b834a6f","value":{"value":"1","alias":"tutorial_vnf"},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"MemberVNFIndex_1","valueType":"TEXT"},{"uuid":"7bec87f6-66ce-4bc2-a75b-64cf01b60306","value":{"value":"null","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"ConstituentVnfrIps","valueType":"TEXT"},{"uuid":"89bd345e-d059-4747-919e-c3c4739b9b08","value":{"value":"[\"null\"]","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"NSLCM","valueType":"TEXT"},{"uuid":"85e4fbee-b04c-44c6-8cad-3397f198e02f","value":{"value":"420fa806-f2f8-405e-8348-11e4fcd13f25","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"InstanceId","valueType":"TEXT"},{"uuid":"ad3e9d1b-9962-4500-9f8e-0b345d787895","value":{"value":"{\"ssh-authorized-key\":[\"\"],\"ns-instance-config-ref\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"affinity-or-anti-affinity-group\":[],\"errorDescription\":null,\"detailed-status\":\"Stage 2/5: deployment of KDUs, VMs and execution environments. 0/4. Deployed at VIM\",\"nsd-ref\":\"tutorial_ns\",\"description\":\"\",\"operational-status\":\"init\",\"operational-events\":[],\"instantiate_params\":{\"ssh_keys\":[\"\"],\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"nsName\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"},\"vnfd-id\":[\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\"],\"shared-volumes\":[],\"currentOperation\":\"INSTANTIATING\",\"deploymentStatus\":null,\"orchestration-progress\":{},\"errorDetail\":null,\"id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"resource-orchestrator\":\"osmopenmano\",\"nsd-id\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"currentOperationID\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"image\":[{\"image\":\"ubuntu-20.04-server-cloudimg-amd64\",\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"c5af64b3-9505-4c27-a286-67da2b400ac8\",\"vim_details\":null,\"vim_status\":\"ACTIVE\"}},\"id\":\"0\"}],\"vcaStatus\":null,\"datacenter\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"constituent-vnfr-ref\":[\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\"],\"create-time\":1.7169792184061038E9,\"short-name\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"additionalParamsForNs\":null,\"revision\":1,\"vld\":[{\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vim_details\":\"{admin_state_up: true, availability_zone_hints: [], availability_zones: [nova], created_at: '2023-03-02T17:27:44Z', description: '', encapsulation: vlan, encapsulation_id: 704, encapsulation_type: vlan, id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, ipv4_address_scope: null,\\n ipv6_address_scope: null, is_default: false, mtu: 1500, name: new_5gasp, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, 'provider:network_type': vlan, 'provider:physical_network': Vlans, 'provider:segmentation_id': 704, revision_number: 5,\\n 'router:external': true, segmentation_id: 704, shared: true, status: ACTIVE, subnets: [{subnet: {allocation_pools: [{end: 10.255.28.254, start: 10.255.28.150}], cidr: 10.255.28.0/24, created_at: '2023-03-02T17:27:44Z', description: '', dns_nameservers: [193.136.92.73,\\n 193.136.92.74], enable_dhcp: true, gateway_ip: 10.255.28.1, host_routes: [], id: f8851549-8399-4bdd-b86b-f7c4798cd9cd, ip_version: 4, ipv6_address_mode: null, ipv6_ra_mode: null, name: 5gasp-subnet, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e,\\n project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 1, service_types: [], subnetpool_id: null, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2023-03-02T23:29:51Z'}}], tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0,\\n type: data, updated_at: '2023-05-02T17:37:14Z'}\\n\",\"vim_account_id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"vim_network_name\":\"new_5gasp\",\"vim_status\":\"ACTIVE\"}},\"mgmt-network\":true,\"name\":\"mgmtnet_2\",\"id\":\"mgmtnet_2\",\"type\":null}],\"flavor\":[{\"storage-gb\":\"10\",\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"b19b9b85-726a-4ee8-bdff-1768803aea5d\",\"vim_details\":null,\"vim_status\":\"ACTIVE\"}},\"memory-mb\":1024,\"name\":\"vdu1-1-1-flv\",\"id\":\"0\",\"vcpu-count\":1},{\"storage-gb\":\"10\",\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"b19b9b85-726a-4ee8-bdff-1768803aea5d\",\"vim_details\":null,\"vim_status\":\"ACTIVE\"}},\"memory-mb\":1024,\"name\":\"vdu2-1-1-flv\",\"id\":\"1\",\"vcpu-count\":1}],\"name-ref\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"_admin\":{\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169792184159737E9,\"operation-type\":\"INSTANTIATING\",\"modified\":1.7169793938838875E9,\"nslcmop\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"deployed\":{\"VCA\":[{\"vdu_id\":null,\"vnfd_id\":\"tutorial_vnf\",\"ee_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25.configure-vn-z0-z1-vnf.2\",\"vdu_count_index\":0,\"detailed-status\":\"\",\"member-vnf-index\":\"1\",\"operational-status\":\"init\",\"ee_descriptor_id\":\"configure-vnf\",\"charm_name\":\"\",\"kdu_name\":null,\"vdu_name\":null,\"type\":\"lxc_proxy_charm\",\"application\":\"configure-vn-z0-z1-vnf\",\"step\":\"initial-deploy\",\"model\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"target_element\":\"vnf/1\"},{\"vdu_id\":\"vdu1\",\"vnfd_id\":\"tutorial_vnf\",\"ee_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25.vdu1-ee-z0-z1-vdu1-z0-vdu.1\",\"vdu_count_index\":0,\"detailed-status\":\"\",\"member-vnf-index\":\"1\",\"operational-status\":\"init\",\"ee_descriptor_id\":\"vdu1-ee\",\"charm_name\":\"\",\"kdu_name\":null,\"vdu_name\":null,\"type\":\"lxc_proxy_charm\",\"config_sw_installed\":true,\"application\":\"vdu1-ee-z0-z1-vdu1-z0-vdu\",\"step\":\"initial-deploy\",\"model\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"target_element\":\"vnf/1/vdu/vdu1/0\"},{\"vdu_id\":\"vdu2\",\"vnfd_id\":\"tutorial_vnf\",\"ee_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25.vdu2-ee-z0-z1-vdu2-z0-vdu.0\",\"vdu_count_index\":0,\"detailed-status\":\"\",\"member-vnf-index\":\"1\",\"operational-status\":\"init\",\"ee_descriptor_id\":\"vdu2-ee\",\"charm_name\":\"\",\"kdu_name\":null,\"vdu_name\":null,\"type\":\"lxc_proxy_charm\",\"config_sw_installed\":true,\"application\":\"vdu2-ee-z0-z1-vdu2-z0-vdu\",\"step\":\"initial-deploy\",\"model\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"target_element\":\"vnf/1/vdu/vdu2/0\"}],\"K8s\":[],\"RO\":{\"vnfd\":[],\"operational-status\":\"running\"}},\"current-operation\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"nsState\":\"INSTANTIATED\"},\"admin-status\":\"ENABLED\",\"nsd-name-ref\":\"tutorial_ns\",\"configurationStatus\":[{\"elementUnderConfiguration\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"elementType\":\"VNF\",\"status\":\"INSTALLING SW\"},{\"elementUnderConfiguration\":\"vdu1-0\",\"elementType\":\"VDU\",\"status\":\"INSTALLING SW\"},{\"elementUnderConfiguration\":\"vdu2-0\",\"elementType\":\"VDU\",\"status\":\"INSTALLING SW\"}],\"config-status\":\"init\",\"name\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"nsState\":\"BUILDING\",\"nsd\":{\"virtual-link-desc\":[{\"mgmt-network\":true,\"vim-network-name\":\"new_5gasp\",\"id\":\"mgmtnet_2\"}],\"df\":[{\"vnf-profile\":[{\"virtual-link-connectivity\":[{\"constituent-cpd-id\":[{\"constituent-cpd-id\":\"vnf-vdu1-ext\",\"constituent-base-element-id\":\"1\"}],\"virtual-link-profile-id\":\"mgmtnet_2\"},{\"constituent-cpd-id\":[{\"constituent-cpd-id\":\"vnf-vdu2-ext\",\"constituent-base-element-id\":\"1\"}],\"virtual-link-profile-id\":\"mgmtnet_2\"}],\"id\":\"1\",\"vnfd-id\":\"tutorial_vnf\"}],\"id\":\"default-df\"}],\"_admin\":{\"usageState\":\"NOT_IN_USE\",\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169336967048578E9,\"modified\":1.7169336969676485E9,\"operationalState\":\"ENABLED\",\"storage\":{\"path\":\"/app/storage/\",\"zipfile\":\"package.tar.gz\",\"folder\":\"338d3a8c-af70-446a-af37-ed8bb97a6641:1\",\"descriptor\":\"tutorial_ns/tutorial_nsd.yaml\",\"fs\":\"mongo\",\"pkg-dir\":\"tutorial_ns\"},\"onboardingState\":\"ONBOARDED\",\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"userDefinedData\":{},\"revision\":1},\"name\":\"tutorial_ns\",\"description\":\"Simple NS with one VNF and a single Virtual Link\",\"_id\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"id\":\"tutorial_ns\",\"version\":\"1.0\",\"vnfd-id\":[\"tutorial_vnf\"]}}","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"NSR","valueType":"TEXT"},{"uuid":"ffc62ede-f9d5-4122-81b4-a177228d122f","value":{"value":"{\"nsName\": \"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\", \"ssh_keys\": [\"\"],\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\", \"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"}","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"APPLY_CONFIG","valueType":"TEXT"},{"uuid":"ee317935-873a-4098-9f2b-0657ffad0709","value":{"value":"OSMvTHIRTEEN","alias":"PackagingFormat"},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"PackagingFormat","valueType":"TEXT"},{"uuid":"aa0b88ca-df0b-400a-83c8-d8348b04aec3","value":{"value":"http://10.255.28.246/osapi/packages/612960a2-878c-468f-990d-e2f6a2a8277c/tutorial_ns.tar.gz","alias":"PackageLocation"},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"PackageLocation","valueType":"TEXT"},{"uuid":"d274700a-095b-4e77-bc94-b27f895c0924","value":{"value":"init","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OperationalStatus","valueType":"TEXT"},{"uuid":"1f094954-636e-4154-b6c8-3d6f23bde9da","value":{"value":"blockdiag {default_textcolor = white;\r\ndefault_fontsize = 12;\r\n\r\n\"8fa5bfa8-4394-40aa-9d29-97c15c5f457a\" -> \"f2bb6576-2525-4c13-897b-954c9f80395b\";\r\n\"f2bb6576-2525-4c13-897b-954c9f80395b\" [ label = \"tutorial_ns\", shape = roundedbox, color = \"#e28743\"]; \"8fa5bfa8-4394-40aa-9d29-97c15c5f457a\" [ label = \"tutorial_ns@osm14\", color = \"#2596be\"]; }","alias":"SSPEC_GRAPH_NOTATION"},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"SSPEC_GRAPH_NOTATION","valueType":"LONGTEXT"},{"uuid":"ada9a1e1-5861-42a1-aa50-272eafe5c25a","value":{"value":"ONBOARDED","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OnBoardingStatus","valueType":"TEXT"},{"uuid":"2885b48f-35b8-4333-ad8e-c9ac0c38da31","value":{"value":null,"alias":"Vendor"},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"Vendor","valueType":"TEXT"},{"uuid":"e1a03f20-a8fe-4618-9518-adc738498f09","value":{"value":"4","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"DeploymentRequestID","valueType":"TEXT"},{"uuid":"9ebc771d-2eb0-4bdb-a326-32f78a51cea2","value":{"value":"","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"VNFINDEXREF_INFO_1","valueType":"TEXT"},{"uuid":"08e48a23-c2b7-40b5-887f-e2a48cea72d4","value":{"value":"init","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"ConfigStatus","valueType":"TEXT"},{"uuid":"37ad7be3-d9ff-463d-b4ee-b6a83a2d3a54","value":{"value":"INSTANTIATING","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"Status","valueType":"TEXT"},{"uuid":"57380d7d-7cee-481f-9eb2-3a075558322c","value":{"value":"{\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\", \"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"}","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OSM_CONFIG","valueType":"TEXT"}],"serviceOrder":[{"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"id":"65bcf307-1a47-4a48-b211-be94c3390b81","serviceOrderItemId":"47ac2dab-c7fe-431d-9d1c-c39980f1de5b","@referredType":null}],"serviceRelationship":[],"serviceSpecification":{"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"tutorial_ns@osm14","version":null,"targetServiceSchema":null,"@referredType":null,"id":"8fa5bfa8-4394-40aa-9d29-97c15c5f457a"},"state":"reserved","supportingResource":[],"supportingService":[]} \ No newline at end of file +{ + "uuid": "910146b3-67e9-4d8f-8141-066c6ca7ab60", + "endDate": "2024-05-30T10:39:42.142Z", + "startDate": "2024-05-29T10:40:07.811452Z", + "description": "A Service for tutorial_ns@osm14", + "@baseType": "BaseRootNamedEntity", + "@schemaLocation": null, + "@type": "ResourceFacingService", + "href": null, + "name": "tutorial_ns@osm14", + "id": "910146b3-67e9-4d8f-8141-066c6ca7ab60", + "category": "ResourceFacingService", + "hasStarted": false, + "isServiceEnabled": false, + "isStateful": null, + "serviceDate": "2024-05-29T10:40:07.811412476Z", + "serviceType": "tutorial_ns@osm14", + "startMode": "AUTOMATICALLY_MANAGED", + "note": [ + { + "uuid": "b5176ca9-a909-4baf-8d42-788296bdb0b0", + "date": "2024-05-29T10:43:26.422075Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "c58afe4b-d265-4c7a-a4fc-c059ccfcd852", + "date": "2024-05-29T10:42:46.354267Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "d6385fda-e220-4e82-ae86-9a0eab68ca97", + "date": "2024-05-29T10:43:06.526422Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "e5eb63a2-0660-4027-bb77-3d5d946854e2", + "date": "2024-05-29T10:40:08.018182Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service reserved" + }, + { + "uuid": "a24a4c0d-91fa-4ac9-b6e0-66d1c9e77fb8", + "date": "2024-05-29T10:40:46.703148Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "76c96e75-a805-4e02-ba36-d0a968fdb772", + "date": "2024-05-29T10:40:10.329551Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: DeploymentRequestID, Status, OperationalStatus, ConstituentVnfrIps, ConfigStatus, APPLY_CONFIG, InstanceId, NSR, NSLCM, " + }, + { + "uuid": "b3c6665c-1ade-465f-abf5-d530d42f9e71", + "date": "2024-05-29T10:42:26.406336Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, NSR, " + }, + { + "uuid": "cd9ead3c-bb20-4032-b451-e79971a179d2", + "date": "2024-05-29T10:41:26.256050Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, NSR, OperationalStatus, ConfigStatus, " + }, + { + "uuid": "d46922a2-96a6-4177-b85d-14ecd5b0e335", + "date": "2024-05-29T10:42:06.544071Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "196621c2-e45b-4c9b-8cef-3386757a565d", + "date": "2024-05-29T10:42:06.389619Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "065341af-6dc1-4b9e-b9f5-026c4da1866f", + "date": "2024-05-29T10:40:10.262832Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "openslice-osom", + "system": null, + "text": "Request to NFVO osm14 with Deployment Request id:4" + }, + { + "uuid": "54465e59-e976-410f-971e-c82fead34c87", + "date": "2024-05-29T10:43:26.320461Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, NSR, " + }, + { + "uuid": "58d14daf-106f-4cfa-98f0-ab9215729cb1", + "date": "2024-05-29T10:44:06.331840Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "7ea7a9fc-c04a-46bc-908f-0c6e9a9b3d5c", + "date": "2024-05-29T10:40:08.006718Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "openslice-osom", + "system": null, + "text": "Service Created by CreateReservedService" + }, + { + "uuid": "73fa711b-6fc9-4933-b836-353464229ce5", + "date": "2024-05-29T10:41:06.420721Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "54e36f92-12e3-40d4-847d-1290980ce831", + "date": "2024-05-29T10:40:26.497483Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, InstanceId, Status, " + }, + { + "uuid": "c1fbfdbb-5efd-47e3-ba82-d04859398660", + "date": "2024-05-29T10:40:10.772955Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "7f6b5dbc-38c4-4524-ba36-3801a070c46b", + "date": "2024-05-29T10:44:06.448514Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "3f6bbca6-a582-4269-81f2-f32da6d7ce58", + "date": "2024-05-29T10:42:46.444646Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "ded38a15-5fdf-4b83-af6a-26e835a9dc5a", + "date": "2024-05-29T10:43:46.366950Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "9f05ea6b-f390-4666-8feb-7dc7e73f4899", + "date": "2024-05-29T10:40:46.361042Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "33abb807-0418-4f0a-b7ef-57b8c6e40e45", + "date": "2024-05-29T10:41:26.377603Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + }, + { + "uuid": "559f81ff-0178-47f1-9e9d-34efef76f48b", + "date": "2024-05-29T10:41:46.362854Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Service Characteristic changed: NSLCM, " + } + ], + "place": [], + "relatedParty": [], + "serviceCharacteristic": [ + { + "uuid": "0126b0b1-96ea-4490-9302-6a61cf7567a7", + "value": { + "value": "338d3a8c-af70-446a-af37-ed8bb97a6641", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "OSM_NSDCATALOGID", + "valueType": "TEXT" + }, + { + "uuid": "ef5df2c3-ff08-43aa-aa28-9b03b3ac72b9", + "value": { + "value": "1", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "MANOproviderID", + "valueType": "TEXT" + }, + { + "uuid": "df7a9636-2897-4ba3-a533-ad3ffe37df2d", + "value": { + "value": "2", + "alias": "id" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "NSDID", + "valueType": "TEXT" + }, + { + "uuid": "fc1987da-497d-47c3-8f03-6c3bf6f10716", + "value": { + "value": "osm14", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "MANOproviderName", + "valueType": "TEXT" + }, + { + "uuid": "9ab40cb6-05e5-4ad3-aeed-e29870de6011", + "value": { + "value": "f6f1ad7f-b312-4ba0-8f21-de1d42cb2451", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "OnBoardDescriptorUUID", + "valueType": "TEXT" + }, + { + "uuid": "58bc2253-0392-4543-8f28-14c1052feb2f", + "value": { + "value": "2", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "OnBoardDescriptorID", + "valueType": "TEXT" + }, + { + "uuid": "927823e7-e6fc-4836-97f0-db5d89b29cde", + "value": { + "value": "", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "SSHKEY", + "valueType": "TEXT" + }, + { + "uuid": "e3d3d14c-cc84-47e0-9688-cffe8b834a6f", + "value": { + "value": "1", + "alias": "tutorial_vnf" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "MemberVNFIndex_1", + "valueType": "TEXT" + }, + { + "uuid": "7bec87f6-66ce-4bc2-a75b-64cf01b60306", + "value": { + "value": "null", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "ConstituentVnfrIps", + "valueType": "TEXT" + }, + { + "uuid": "89bd345e-d059-4747-919e-c3c4739b9b08", + "value": { + "value": "", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "NSLCM", + "valueType": "TEXT" + }, + { + "uuid": "85e4fbee-b04c-44c6-8cad-3397f198e02f", + "value": { + "value": "420fa806-f2f8-405e-8348-11e4fcd13f25", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "InstanceId", + "valueType": "TEXT" + }, + { + "uuid": "ad3e9d1b-9962-4500-9f8e-0b345d787895", + "value": { + "value": "{\"ssh-authorized-key\":[\"\"],\"ns-instance-config-ref\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"affinity-or-anti-affinity-group\":[],\"errorDescription\":null,\"detailed-status\":\"Stage 2/5: deployment of KDUs, VMs and execution environments. 0/4. Deployed at VIM\",\"nsd-ref\":\"tutorial_ns\",\"description\":\"\",\"operational-status\":\"init\",\"operational-events\":[],\"instantiate_params\":{\"ssh_keys\":[\"\"],\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"nsName\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"},\"vnfd-id\":[\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\"],\"shared-volumes\":[],\"currentOperation\":\"INSTANTIATING\",\"deploymentStatus\":null,\"orchestration-progress\":{},\"errorDetail\":null,\"id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"resource-orchestrator\":\"osmopenmano\",\"nsd-id\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"currentOperationID\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"image\":[{\"image\":\"ubuntu-20.04-server-cloudimg-amd64\",\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"c5af64b3-9505-4c27-a286-67da2b400ac8\",\"vim_details\":null,\"vim_status\":\"ACTIVE\"}},\"id\":\"0\"}],\"vcaStatus\":null,\"datacenter\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"constituent-vnfr-ref\":[\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\"],\"create-time\":1.7169792184061038E9,\"short-name\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"additionalParamsForNs\":null,\"revision\":1,\"vld\":[{\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vim_details\":\"{admin_state_up: true, availability_zone_hints: [], availability_zones: [nova], created_at: '2023-03-02T17:27:44Z', description: '', encapsulation: vlan, encapsulation_id: 704, encapsulation_type: vlan, id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, ipv4_address_scope: null,\\n ipv6_address_scope: null, is_default: false, mtu: 1500, name: new_5gasp, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, 'provider:network_type': vlan, 'provider:physical_network': Vlans, 'provider:segmentation_id': 704, revision_number: 5,\\n 'router:external': true, segmentation_id: 704, shared: true, status: ACTIVE, subnets: [{subnet: {allocation_pools: [{end: 10.255.28.254, start: 10.255.28.150}], cidr: 10.255.28.0/24, created_at: '2023-03-02T17:27:44Z', description: '', dns_nameservers: [193.136.92.73,\\n 193.136.92.74], enable_dhcp: true, gateway_ip: 10.255.28.1, host_routes: [], id: f8851549-8399-4bdd-b86b-f7c4798cd9cd, ip_version: 4, ipv6_address_mode: null, ipv6_ra_mode: null, name: 5gasp-subnet, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e,\\n project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 1, service_types: [], subnetpool_id: null, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2023-03-02T23:29:51Z'}}], tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0,\\n type: data, updated_at: '2023-05-02T17:37:14Z'}\\n\",\"vim_account_id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"vim_network_name\":\"new_5gasp\",\"vim_status\":\"ACTIVE\"}},\"mgmt-network\":true,\"name\":\"mgmtnet_2\",\"id\":\"mgmtnet_2\",\"type\":null}],\"flavor\":[{\"storage-gb\":\"10\",\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"b19b9b85-726a-4ee8-bdff-1768803aea5d\",\"vim_details\":null,\"vim_status\":\"ACTIVE\"}},\"memory-mb\":1024,\"name\":\"vdu1-1-1-flv\",\"id\":\"0\",\"vcpu-count\":1},{\"storage-gb\":\"10\",\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"b19b9b85-726a-4ee8-bdff-1768803aea5d\",\"vim_details\":null,\"vim_status\":\"ACTIVE\"}},\"memory-mb\":1024,\"name\":\"vdu2-1-1-flv\",\"id\":\"1\",\"vcpu-count\":1}],\"name-ref\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"_admin\":{\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169792184159737E9,\"operation-type\":\"INSTANTIATING\",\"modified\":1.7169793938838875E9,\"nslcmop\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"deployed\":{\"VCA\":[{\"vdu_id\":null,\"vnfd_id\":\"tutorial_vnf\",\"ee_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25.configure-vn-z0-z1-vnf.2\",\"vdu_count_index\":0,\"detailed-status\":\"\",\"member-vnf-index\":\"1\",\"operational-status\":\"init\",\"ee_descriptor_id\":\"configure-vnf\",\"charm_name\":\"\",\"kdu_name\":null,\"vdu_name\":null,\"type\":\"lxc_proxy_charm\",\"application\":\"configure-vn-z0-z1-vnf\",\"step\":\"initial-deploy\",\"model\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"target_element\":\"vnf/1\"},{\"vdu_id\":\"vdu1\",\"vnfd_id\":\"tutorial_vnf\",\"ee_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25.vdu1-ee-z0-z1-vdu1-z0-vdu.1\",\"vdu_count_index\":0,\"detailed-status\":\"\",\"member-vnf-index\":\"1\",\"operational-status\":\"init\",\"ee_descriptor_id\":\"vdu1-ee\",\"charm_name\":\"\",\"kdu_name\":null,\"vdu_name\":null,\"type\":\"lxc_proxy_charm\",\"config_sw_installed\":true,\"application\":\"vdu1-ee-z0-z1-vdu1-z0-vdu\",\"step\":\"initial-deploy\",\"model\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"target_element\":\"vnf/1/vdu/vdu1/0\"},{\"vdu_id\":\"vdu2\",\"vnfd_id\":\"tutorial_vnf\",\"ee_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25.vdu2-ee-z0-z1-vdu2-z0-vdu.0\",\"vdu_count_index\":0,\"detailed-status\":\"\",\"member-vnf-index\":\"1\",\"operational-status\":\"init\",\"ee_descriptor_id\":\"vdu2-ee\",\"charm_name\":\"\",\"kdu_name\":null,\"vdu_name\":null,\"type\":\"lxc_proxy_charm\",\"config_sw_installed\":true,\"application\":\"vdu2-ee-z0-z1-vdu2-z0-vdu\",\"step\":\"initial-deploy\",\"model\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"target_element\":\"vnf/1/vdu/vdu2/0\"}],\"K8s\":[],\"RO\":{\"vnfd\":[],\"operational-status\":\"running\"}},\"current-operation\":\"e0836187-7d4a-49ac-a317-fc4108ed2f93\",\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"nsState\":\"INSTANTIATED\"},\"admin-status\":\"ENABLED\",\"nsd-name-ref\":\"tutorial_ns\",\"configurationStatus\":[{\"elementUnderConfiguration\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"elementType\":\"VNF\",\"status\":\"INSTALLING SW\"},{\"elementUnderConfiguration\":\"vdu1-0\",\"elementType\":\"VDU\",\"status\":\"INSTALLING SW\"},{\"elementUnderConfiguration\":\"vdu2-0\",\"elementType\":\"VDU\",\"status\":\"INSTALLING SW\"}],\"config-status\":\"init\",\"name\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"nsState\":\"BUILDING\",\"nsd\":{\"virtual-link-desc\":[{\"mgmt-network\":true,\"vim-network-name\":\"new_5gasp\",\"id\":\"mgmtnet_2\"}],\"df\":[{\"vnf-profile\":[{\"virtual-link-connectivity\":[{\"constituent-cpd-id\":[{\"constituent-cpd-id\":\"vnf-vdu1-ext\",\"constituent-base-element-id\":\"1\"}],\"virtual-link-profile-id\":\"mgmtnet_2\"},{\"constituent-cpd-id\":[{\"constituent-cpd-id\":\"vnf-vdu2-ext\",\"constituent-base-element-id\":\"1\"}],\"virtual-link-profile-id\":\"mgmtnet_2\"}],\"id\":\"1\",\"vnfd-id\":\"tutorial_vnf\"}],\"id\":\"default-df\"}],\"_admin\":{\"usageState\":\"NOT_IN_USE\",\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169336967048578E9,\"modified\":1.7169336969676485E9,\"operationalState\":\"ENABLED\",\"storage\":{\"path\":\"/app/storage/\",\"zipfile\":\"package.tar.gz\",\"folder\":\"338d3a8c-af70-446a-af37-ed8bb97a6641:1\",\"descriptor\":\"tutorial_ns/tutorial_nsd.yaml\",\"fs\":\"mongo\",\"pkg-dir\":\"tutorial_ns\"},\"onboardingState\":\"ONBOARDED\",\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"userDefinedData\":{},\"revision\":1},\"name\":\"tutorial_ns\",\"description\":\"Simple NS with one VNF and a single Virtual Link\",\"_id\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"id\":\"tutorial_ns\",\"version\":\"1.0\",\"vnfd-id\":[\"tutorial_vnf\"]}}", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "NSR", + "valueType": "TEXT" + }, + { + "uuid": "ffc62ede-f9d5-4122-81b4-a177228d122f", + "value": { + "value": "{\"nsName\": \"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\", \"ssh_keys\": [\"\"],\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\", \"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"}", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "APPLY_CONFIG", + "valueType": "TEXT" + }, + { + "uuid": "ee317935-873a-4098-9f2b-0657ffad0709", + "value": { + "value": "OSMvTHIRTEEN", + "alias": "PackagingFormat" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "PackagingFormat", + "valueType": "TEXT" + }, + { + "uuid": "aa0b88ca-df0b-400a-83c8-d8348b04aec3", + "value": { + "value": "http://10.255.28.246/osapi/packages/612960a2-878c-468f-990d-e2f6a2a8277c/tutorial_ns.tar.gz", + "alias": "PackageLocation" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "PackageLocation", + "valueType": "TEXT" + }, + { + "uuid": "d274700a-095b-4e77-bc94-b27f895c0924", + "value": { + "value": "init", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "OperationalStatus", + "valueType": "TEXT" + }, + { + "uuid": "1f094954-636e-4154-b6c8-3d6f23bde9da", + "value": { + "value": "blockdiag {default_textcolor = white;\r\ndefault_fontsize = 12;\r\n\r\n\"8fa5bfa8-4394-40aa-9d29-97c15c5f457a\" -> \"f2bb6576-2525-4c13-897b-954c9f80395b\";\r\n\"f2bb6576-2525-4c13-897b-954c9f80395b\" [ label = \"tutorial_ns\", shape = roundedbox, color = \"#e28743\"]; \"8fa5bfa8-4394-40aa-9d29-97c15c5f457a\" [ label = \"tutorial_ns@osm14\", color = \"#2596be\"]; }", + "alias": "SSPEC_GRAPH_NOTATION" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "SSPEC_GRAPH_NOTATION", + "valueType": "LONGTEXT" + }, + { + "uuid": "ada9a1e1-5861-42a1-aa50-272eafe5c25a", + "value": { + "value": "ONBOARDED", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "OnBoardingStatus", + "valueType": "TEXT" + }, + { + "uuid": "2885b48f-35b8-4333-ad8e-c9ac0c38da31", + "value": { + "value": null, + "alias": "Vendor" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "Vendor", + "valueType": "TEXT" + }, + { + "uuid": "e1a03f20-a8fe-4618-9518-adc738498f09", + "value": { + "value": "4", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "DeploymentRequestID", + "valueType": "TEXT" + }, + { + "uuid": "9ebc771d-2eb0-4bdb-a326-32f78a51cea2", + "value": { + "value": "", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "VNFINDEXREF_INFO_1", + "valueType": "TEXT" + }, + { + "uuid": "08e48a23-c2b7-40b5-887f-e2a48cea72d4", + "value": { + "value": "init", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "ConfigStatus", + "valueType": "TEXT" + }, + { + "uuid": "37ad7be3-d9ff-463d-b4ee-b6a83a2d3a54", + "value": { + "value": "INSTANTIATING", + "alias": null + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "Status", + "valueType": "TEXT" + }, + { + "uuid": "57380d7d-7cee-481f-9eb2-3a075558322c", + "value": { + "value": "{\"nsdId\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\", \"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"}", + "alias": "" + }, + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "OSM_CONFIG", + "valueType": "TEXT" + } + ], + "serviceOrder": [ + { + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "id": "65bcf307-1a47-4a48-b211-be94c3390b81", + "serviceOrderItemId": "47ac2dab-c7fe-431d-9d1c-c39980f1de5b", + "@referredType": null + } + ], + "serviceRelationship": [], + "serviceSpecification": { + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "tutorial_ns@osm14", + "version": null, + "targetServiceSchema": null, + "@referredType": null, + "id": "8fa5bfa8-4394-40aa-9d29-97c15c5f457a" + }, + "state": "reserved", + "supportingResource": [], + "supportingService": [] +} \ No newline at end of file diff --git a/src/test/resources/productorder.json b/src/test/resources/productorder.json new file mode 100644 index 0000000000000000000000000000000000000000..c4d24ce8a5a4b2373c833b6b1bd7f95e609bb9a8 --- /dev/null +++ b/src/test/resources/productorder.json @@ -0,0 +1,235 @@ +{ +"category": "B2C product order", +"description": "Product Order illustration sample", +"externalId": "PO-456", +"priority": "1", +"requestedCompletionDate": "2019-05-02T08:13:59.506Z", +"requestedStartDate": "2019-05-03T08:13:59.506Z", +"channel": [ +{ +"id": "1", +"role": "Used channel for order capture", +"name": "Online chanel" +} +], +"note": [ +{ +"id": "1", +"author": "Jean Pontus", +"date": "2019-04-30T08:13:59.509Z", +"text": "This is a TMF product order illustration" +} +], +"productOrderItem": [ +{ +"id": "100", +"quantity": 1, +"action": "add", +"productOffering": { +"id": "14277", +"href": "https://host:port/productCatalogManagement/v4/productOffering/14277", +"name": "TMF25" +}, +"productOrderItemRelationship": [ +{ +"id": "110", +"relationshipType": "bundles" +}, +{ +"id": "120", +"relationshipType": "bundles" +}, +{ +"id": "130", +"relationshipType": "bundles" +} +], +"@type": "ProductOrderItem" +}, +{ +"id": "110", +"quantity": 1, +"action": "add", +"itemPrice": [ +{ +"description": "Access Fee", +"name": "Access Fee", +"priceType": "nonRecurring", +"price": { +"taxRate": 0, +"dutyFreeAmount": { +"unit": "EUR", +"value": 0.99 +}, +"taxIncludedAmount": { +"unit": "EUT", +"value": 0.99 +} +} +} +], +"payment": [ +{ +"id": "2365", +"href": "https://host:port/paymentManagement/v4/cashPayment/2365", +"name": "Cash payment for access fee", +"@type": "CashPayment", +"@referredType": "Payment" +} +], +"product": { +"isBundle": false, +"@type": "Product", +"productCharacteristic": [ +{ +"name": "TEL_MSISDN", +"valueType": "string", +"value": "415 279 7439" +} +], +"productSpecification": { +"id": "14307", +"href": "https://host:port/productCatalogManagement/v4/productSpecification/14307", +"name": "Mobile Telephony", +"version": "1", +"@type": "ProductSpecificationRef" +} +}, +"productOffering": { +"id": "14305", +"href": "https://host:port/productCatalogManagement/v4/productOffering/14305", +"name": "TMF Mobile Telephony" +}, +"@type": "ProductOrderItem" +}, +{ +"id": "120", +"quantity": 1, +"action": "add", +"billingAccount": { +"id": "1513", +"href": "https://host:port/billingAccountManagement/v4/billingAccount/1513", +"@type": "BillingAccount" +}, +"itemPrice": [ +{ +"description": "Tariff plan monthly fee", +"name": "MonthlyFee", +"priceType": "recurring", +"recurringChargePeriod": "month", +"price": { +"taxRate": 0, +"dutyFreeAmount": { +"unit": "EUR", +"value": 20 +}, +"taxIncludedAmount": { +"unit": "EUR", +"value": 20 +} +}, +"priceAlteration": [ +{ +"applicationDuration": 3, +"description": "20% for first 3 months", +"name": "WelcomeDiscount", +"priceType": "recurring", +"priority": 1, +"recurringChargePeriod": "month", +"price": { +"percentage": 20, +"taxRate": 0, +"@type": "price" +} +} +] +} +], +"itemTerm": [ +{ +"description": "Tariff plan 12 Months commitment", +"name": "12Months", +"duration": { +"amount": 12, +"units": "month" +} +} +], +"product": { +"isBundle": false, +"@type": "Product", +"productSpecification": { +"id": "14395", +"href": "https://host:port/productCatalogManagement/v4/productSpecification/14395", +"name": "TMF Tariff plan", +"version": "1", +"@type": "ProductSpecificationRef" +} +}, +"productOffering": { +"id": "14344", +"href": "https://host:port/productCatalogManagement/v4/productOffering/14344" +}, +"productOrderItemRelationship": [ +{ +"id": "110", +"relationshipType": "reliesOn" +} +], +"@type": "ProductOrderItem" +}, +{ +"id": "130", +"quantity": 1, +"action": "add", +"product": { +"isBundle": false, +"@type": "Product", +"productCharacteristic": [ +{ +"name": "CoverageOptions", +"valueType": "string", +"value": "National" +} +], +"productSpecification": { +"id": "14353", +"href": "https://host:port/productCatalogManagement/v4/productSpecification/14353", +"name": "Coverage", +"version": "1", +"@type": "ProductSpecificationRef" +} +}, +"productOffering": { +"id": "14354", +"href": "https://host:port/productCatalogManagement/v4/productOffering/14354", +"name": "Coverage Options" +}, +"productOrderItemRelationship": [ +{ +"id": "110", +"relationshipType": "reliesOn" +} +], +"@type": "ProductOrderItem" +} +], +"relatedParty": [ +{ +"id": "456-dd-df45", +"href": "https://host:port/partyManagement/v4/individual/456-dd-df45", +"name": "Joe Doe", +"role": "Seller", +"@type": "RelatedParty", +"@referredType": "Individual" +}, +{ +"id": "ff55-hjy4", +"href": "https://host:port/partyRoleManagement/v4/customer/ff55-hjy4", +"name": "Jean Pontus", +"@type": "RelatedParty", +"@referredType": "Customer" +} +], +"@type": "ProductOrder" +} \ No newline at end of file diff --git a/src/test/resources/reposervices/ram702/resource.json b/src/test/resources/reposervices/ram702/resource.json new file mode 100644 index 0000000000000000000000000000000000000000..609d70d4f3ca0813c7a44862fef56d851c971b99 --- /dev/null +++ b/src/test/resources/reposervices/ram702/resource.json @@ -0,0 +1,61 @@ +{ + "uuid": "eec4bf3c-3698-4815-b205-70b43df083d4", + "endOperatingDate": "2024-09-24T11:43:57.355Z", + "startOperatingDate": "2024-09-23T11:45:13.347536Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "test_resource", + "id": "eec4bf3c-3698-4815-b205-70b43df083d4", + "category": "test_category", + "description": "A test resource", + "resourceVersion": "1.0", + "activationFeature": [], + "administrativeState": null, + "attachment": [], + "note": [ + { + "uuid": "312ec354-1a82-4f54-b1ad-e36ce81301ba", + "date": "2024-09-24T10:52:41.912820494Z", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "author": "API", + "system": null, + "text": "Resource status: null" + } + ], + "operationalState": null, + "place": null, + "relatedParty": [ + { + "uuid": "bdfa090e-2dbf-4b61-ab02-b28eaa946423", + "@baseType": "BaseRootEntity", + "@schemaLocation": null, + "@type": "org.etsi.osl.tmf.prm669.model.RelatedParty", + "href": null, + "name": "admin", + "role": "REQUESTER", + "@referredType": "SimpleUsername_Individual", + "id": "admin", + "extendedInfo": "" + } + ], + "resourceCharacteristic": [], + "resourceRelationship": [], + "resourceSpecification": { + "@baseType": "BaseRootEntity", + "@schemaLocation": null, + "@type": "org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef", + "href": null, + "name": "Application@argoproj.io/v1alpha1@default@https://10.255.28.198:6443/", + "version": null, + "@referredType": null, + "id": "87094d78-75c2-4876-9a75-d3cc34119915" + }, + "resourceStatus": "AVAILABLE", + "usageState": "ACTIVE", + "value": null +} \ No newline at end of file diff --git a/src/test/resources/reposervices/ram702/resourceCreate.json b/src/test/resources/reposervices/ram702/resourceCreate.json new file mode 100644 index 0000000000000000000000000000000000000000..59d75d8230583d50ebcac08dc99cd52a0966e290 --- /dev/null +++ b/src/test/resources/reposervices/ram702/resourceCreate.json @@ -0,0 +1,35 @@ +{ + "endOperatingDate": "2024-09-24T11:43:57.355Z", + "startOperatingDate": "2024-09-23T11:45:13.347536Z", + "atBaseType": null, + "atSchemaLocation": null, + "atType": null, + "category": null, + "description": null, + "name": "test_resource", + "resourceVersion": null, + "activationFeature": null, + "administrativeState": null, + "attachment": null, + "note": null, + "operationalState": null, + "place": null, + "relatedParty": null, + "resourceCharacteristic": null, + "resourceRelationship": null, + "resourceSpecification": { + "@baseType": "BaseRootEntity", + "@schemaLocation": null, + "@type": "org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef", + "href": null, + "name": "Application@argoproj.io/v1alpha1@default@https://10.255.28.198:6443/", + "version": null, + "@referredType": null, + "id": "87094d78-75c2-4876-9a75-d3cc34119915" + }, + "resourceStatus": null, + "usageState": null, + "@baseType": null, + "@schemaLocation": null, + "@type": null +} \ No newline at end of file diff --git a/src/test/resources/testMeasurementCollectionJobFVO.json b/src/test/resources/testMeasurementCollectionJobFVO.json new file mode 100644 index 0000000000000000000000000000000000000000..3854d4e47a8bacd2af998805f2ffdf3033c27a8e --- /dev/null +++ b/src/test/resources/testMeasurementCollectionJobFVO.json @@ -0,0 +1,271 @@ +{ + "consumingApplicationId": "4000", + "creationTime": "2020-06-23T14:12:01.078Z", + "jobId": "400", + "jobPriority": 3, + "lastModifiedTime": "2020-06-23T14:12:01.079Z", + "outputFormat": "string", + "producingApplicationId": "NT_101", + "adminState": "locked", + "executionState": "acknowledged", + "fileTransferData": [ + { + "fileFormat": "csv", + "fileLocation": "https://host:port/tmf-api/performanceManagement/v5/FileTransferData", + "transportProtocol": "ftp", + "compressionType": { + "compressionEnumType": "no_compression" + }, + "packingType": { + "packingEnumType": "NO_PACKING" + }, + "retentionPeriod": { + "amount": 1, + "units": "month" + }, + "@baseType": "FileTransferData", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/fileTransferLocation", + "@type": "FileTransferData" + } + ], + "granularity": "g_1mn", + "performanceIndicatorGroupSpecification": [ + { + "name": "My critical performance indicators", + "groupCategory": "CPUGroup", + "performanceIndicatorSpecification": [ + { + "uuid": "5000", + "href": "https://host:port/tmf-api/performanceManagement/v5/performanceIndicatorSpecification/5000", + "@type": "PerformanceIndicatorSpecificationRef" + } + ], + "@baseType": "PerformanceIndicatorGroupSpecification", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/PerformanceIndicatorGroupSpecification.schema.json", + "@type": "PerformanceIndicatorGroupSpecification" + } + ], + "performanceIndicatorSpecification": [ + { + "uuid": "101", + "href": "https://host:port/tmf-api/performanceManagement/v5/performanceIndicatorSpecification/101", + "derivationAlgorithm": "na", + "derivationMethod": "average", + "description": "The average CPU speed", + "indicatorCategory": "CPU", + "indicatorUnit": "GHz", + "name": "CPU Speed", + "perspective": "aggregation over a collection of systems", + "collectionType": "cumulative", + "indicatorType": "float", + "performanceIndicatorSpecRelationship": [ + { + "uuid": "321", + "href": "https://host:port/tmf-api/performanceManagement/v5/performanceIndicatorSpecRelationship/321", + "relationshipType": "reliesOn", + "validFor": { + "endDateTime": "1985-04-12T23:20:50.52Z", + "startDateTime": "1985-04-12T23:20:50.52Z" + }, + "@baseType": "PerformanceIndicatorSpecRelationship", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/PerformanceIndicatorSpecRelationship.schema.json", + "@type": "PerformanceIndicatorSpecRelationship" + } + ], + "validFor": { + "endDateTime": "1985-04-12T23:20:50.52Z", + "startDateTime": "1985-04-12T23:20:50.52Z" + }, + "@baseType": "PerformanceIndicatorSpecification", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/PerformanceIndicatorSpecification.schema.json", + "@type": "PerformanceIndicatorSpecification" + } + ], + "reportingPeriod": "r_1mn", + "scheduleDefinition": [ + { + "recurringFrequency": "weekly", + "scheduleDefinitionEndTime": "2020-06-23T14:12:01.080Z", + "scheduleDefinitionHourRange": "2", + "scheduleDefinitionStartTime": "2020-06-23T14:12:01.080Z", + "WeeklyScheduledDefinition": [ + { + "dates": "2020-06-23T14:12:01.080Z", + "@baseType": "WeeklyScheduledDefinition", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/WeeklyScheduledDefinition.schema.json", + "@type": "WeeklyScheduledDefinition" + } + ], + "@baseType": "ScheduleDefinition", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/ScheduleDefinition.schema.json", + "@type": "ScheduleDefinition" + }, + { + "recurringFrequency": "daily", + "scheduleDefinitionEndTime": "2026-06-23T14:12:01.080Z", + "scheduleDefinitionHourRange": "3", + "scheduleDefinitionStartTime": "2024-06-23T14:12:01.080Z", + "excludedDate": [ + "2024-07-23T14:12:01.080Z", + "2024-08-23T14:12:01.080Z" + ], + "WeeklyScheduledDefinition": [ + { + "dates": "2020-06-23T14:12:01.080Z", + "@baseType": "WeeklyScheduledDefinition", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/WeeklyScheduledDefinition.schema.json", + "@type": "WeeklyScheduledDefinition" + }, + { + "dates": "2025-06-23T14:12:01.080Z", + "@baseType": "WeeklyScheduledDefinition", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/WeeklyScheduledDefinition.schema.json", + "@type": "WeeklyScheduledDefinition" + } + ], + "monthlyScheduleDayOfMonthDefinition": [ + "2024-09-23T14:12:01.080Z", + "2024-10-23T14:12:01.080Z" + ], + "MonthlyScheduleDayOfWeekDefinition": { + "dayOfMonthRecurrence": [ + { + "dates": "2025-06-23T14:12:01.080Z", + "@baseType": "DayOfMonthRecurrence", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/DayOfMonthRecurrence.schema.json", + "@type": "DayOfMonthRecurrence" + }, + { + "dates": "2025-07-23T14:12:01.080Z", + "@baseType": "DayOfMonthRecurrence", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/DayOfMonthRecurrence.schema.json", + "@type": "DayOfMonthRecurrence" + } + ], + "recurringDaySequence": "first", + "@baseType": "MonthlyScheduleDayOfWeekDefinition", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/MonthlyScheduleDayOfWeekDefinition.schema.json", + "@type": "MonthlyScheduleDayOfWeekDefinition" + }, + "dateScheduleDefintion": [ + "2024-11-23T14:12:01.080Z", + "2024-12-23T14:12:01.080Z" + ], + "@baseType": "ScheduleDefinition", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/schemas/Tmf/common/ScheduleDefinition.schema.json", + "@type": "ScheduleDefinition" + } + ], + "trackingRecord": [ + { + "href": "https://host:port/tmf-api/performanceManagement/v5/fileTransferLocation", + "description": "NT_101 tracking", + "systemId": "NT_101", + "time": "2020-06-23T17:55:51.671Z", + "user": "NP1", + "@baseType": "TrackingRecord", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/fileTransferLocation", + "@type": "TrackingRecord" + } + ], + "dataAccessEndpoint": [ + { + "href": "https://host:port/tmf-api/performanceManagement/v5/dataAccessEndpoint/123-xxx", + "apiType": "REST", + "category": "topic", + "description": "Measurement collection job 123-xxx subscriber topic", + "endOperatingDate": "2022-05-13T10:13:42.971Z", + "name": "123-xxx subscriber topic", + "resourceVersion": "1.0", + "startOperatingDate": "2022-05-13T10:13:42.971Z", + "uri": "https://pubsub.googleapis.com/v1/", + "uriQueryFilter": { + "mappings": [ + { + "filterTemplate": { + "name": "myRangeFilterSearch0", + "@type": "DataFilterTemplateRange", + "description": "A Test filter template" + }, + "stringArray": { + "value": [ + "field01", + "field02", + "field03" + ], + "@type": "DataFilterAttributeStringArray" + } + }, + { + "filterTemplate": { + "name": "myRegExSampleSearch0", + "@type": "DataFilterTemplateRegex", + "description": "Another test filter template" + }, + "stringArray": { + "value": [ + "field11", + "field12", + "field13" + ], + "@type": "DataFilterAttributeStringArray" + } + }, + { + "filterTemplate": { + "name": "myBooleanFilterSearch0", + "@type": "DataFilterTemplateBoolean" + }, + "stringArray": { + "value": [ + "field1", + "field2", + "field3" + ], + "@type": "DataFilterAttributeStringArray" + } + } + ], + "@type": "DataFilterMap" + }, + "value": "myLogicalResourceValue", + "administrativeState": "locked", + "operationalState": "enable", + "resourceCharacteristic": [ + { + "name": "myCharName", + "valueType": "string", + "characteristicRelationship": [ + { + "relationshipType": "string", + "@baseType": "CharacteristicRelationship", + "@schemaLocation": "https://myschemas.com/CharacteristicRelationship.schema.json", + "@type": "CharacteristicRelationship" + } + ], + "@baseType": "Characteristic", + "@schemaLocation": "https://myschemas.com/StringCharacteristic.schema.json", + "@type": "StringCharacteristic" + } + ], + "resourceSpecification": { + "id": "1", + "href": "https://host:port/tmf-api/performanceManagement/v5/ResourceSpecification/1", + "name": "mySpecName", + "version": "1.0", + "@baseType": "ResourceSpecification", + "@schemaLocation": "https://mySchemas.com/ResourceSpecification.schema.json", + "@type": "ResourceSpecification", + "@referredType": "ResourceSpecification" + }, + "resourceStatus": "standby", + "usageState": "idle", + "@baseType": "DataAccessEndpoint", + "@schemaLocation": "https://myschemas.com/dataAccessEndpoint", + "@type": "DataAccessEndpoint" + } + ], + "@baseType": "MeasurementCollectionJob", + "@schemaLocation": "https://host:port/tmf-api/performanceManagement/v5/fileTransferLocation", + "@type": "MeasurementCollectionJob" +} \ No newline at end of file diff --git a/src/test/resources/testServiceSpec2.json b/src/test/resources/testServiceSpec2.json index 13e648d6256c026bc134c9418cb6deccbadbb96e..987a2cc155634ec91b4b83b1e7da970df2d9ce38 100644 --- a/src/test/resources/testServiceSpec2.json +++ b/src/test/resources/testServiceSpec2.json @@ -73,6 +73,35 @@ } } ] + }, + { + "name": "Spec2Attribute3", + "configurable": false, + "description": "This attribute specifies the zzzxxx", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 10, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "SMALLINT", + "validFor": null, + "value": { + "value": "2", + "alias": "xxx" + } + } + ] } ] }