From 9839849afae52b40b3654490fba00233bfd825b3 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 7 Aug 2024 20:07:19 +0300 Subject: [PATCH 01/59] tests --- pom.xml | 2 + .../SwaggerDocumentationConfig.java | 86 +++-- .../etsi/osl/tmf/pim637/api/ApiException.java | 10 + .../osl/tmf/pim637/api/ApiOriginFilter.java | 30 ++ .../tmf/pim637/api/ApiResponseMessage.java | 69 ++++ .../org/etsi/osl/tmf/pim637/api/HubApi.java | 77 ++++ .../osl/tmf/pim637/api/HubApiController.java | 57 +++ .../etsi/osl/tmf/pim637/api/ListenerApi.java | 158 ++++++++ .../tmf/pim637/api/ListenerApiController.java | 117 ++++++ .../osl/tmf/pim637/api/NotFoundException.java | 10 + .../etsi/osl/tmf/pim637/api/ProductApi.java | 158 ++++++++ .../tmf/pim637/api/ProductApiController.java | 112 ++++++ .../tmf/po622/api/ListenerApiController.java | 2 +- .../osl/tmf/po622/api/ProductOrderApi.java | 3 +- .../po622/api/ProductOrderApiController.java | 97 ++++- .../po622/repo/ProductOrderRepository.java | 55 +++ .../reposervices/ProductOrderRepoService.java | 257 ++++++++++++ .../po622/ProductOrderRepoServiceTest.java | 365 ++++++++++++++++++ 18 files changed, 1628 insertions(+), 37 deletions(-) create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/ApiException.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/ApiOriginFilter.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/ApiResponseMessage.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/HubApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/HubApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/ListenerApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/NotFoundException.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/ProductApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pim637/api/ProductApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/po622/repo/ProductOrderRepository.java create mode 100644 src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java create mode 100644 src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java diff --git a/pom.xml b/pom.xml index 885c306..cd2166e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,8 @@ org.etsi.osl.tmf.api org.etsi.osl.tmf.api + ${org.etsi.osl.tmf.api.version>} + UTF-8 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 239be29..8c74d14 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 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 0000000..dee19e4 --- /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 0000000..653abc4 --- /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 0000000..8bf7d4c --- /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 0000000..7dc3b86 --- /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 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 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 0000000..19e6954 --- /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 +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 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(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 0000000..8ea75df --- /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 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 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 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 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 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 0000000..475d90f --- /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 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(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 0000000..37767fe --- /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 0000000..c4f9f78 --- /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 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 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> 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 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 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 0000000..f53ce22 --- /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 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity> 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>(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>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity 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(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(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + +} 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 540440c..0a183b7 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 b3851c5..10da8d5 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,7 @@ package org.etsi.osl.tmf.po622.api; import java.io.IOException; +import java.security.Principal; import java.util.List; import java.util.Optional; @@ -79,7 +80,7 @@ public interface ProductOrderApi { produces = { "application/json;charset=utf-8" }, consumes = { "application/json;charset=utf-8" }, method = RequestMethod.POST) - default ResponseEntity createProductOrder(@Parameter(description = "The ProductOrder to be created" ,required=true ) @Valid @RequestBody ProductOrderCreate body + default ResponseEntity 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")) { 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 bf80e2d..4414d2f 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,22 +19,42 @@ */ package org.etsi.osl.tmf.po622.api; +import java.security.Principal; import java.util.Optional; import com.fasterxml.jackson.databind.ObjectMapper; - +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.reposervices.ProductOrderRepoService; +import org.etsi.osl.tmf.so641.api.NotFoundException; +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.authentication.UsernamePasswordAuthenticationToken; +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; +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 +@Controller("ProductOrderApiController622") @RequestMapping("/productOrderingManagement/v4/") public class ProductOrderApiController implements ProductOrderApi { private final ObjectMapper objectMapper; private final HttpServletRequest request; + + + + @Autowired + ProductOrderRepoService productOrderRepoService; @org.springframework.beans.factory.annotation.Autowired public ProductOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { @@ -42,14 +62,71 @@ public class ProductOrderApiController implements ProductOrderApi { this.request = request; } - @Override - public Optional getObjectMapper() { - return Optional.ofNullable(objectMapper); - } + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) @Override - public Optional getRequest() { - return Optional.ofNullable(request); - } + public ResponseEntity 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 { + + } + + + + + + + ProductOrder c = productOrderRepoService.addProductOrder(productOrder); + + return new ResponseEntity(c, HttpStatus.OK); + + + } catch (NotFoundException e) { + log.error("Couldn't create Service Order. ", e); + return new ResponseEntity(HttpStatus.BAD_REQUEST); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } } 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 0000000..0569c0c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/repo/ProductOrderRepository.java @@ -0,0 +1,55 @@ +/*- + * ========================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, PagingAndSortingRepository { + + + Optional findByUuid(String id); + Iterable 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 findByRolenameAndRoleType(String rolename, UserPartRoleType requester); + @Query("SELECT por FROM ProductOrder por JOIN FETCH por.relatedParty rp WHERE rp.name = ?1") + Iterable findByRolename(String rolename); + + List findByOrderByOrderDateDesc(); + + @Query("SELECT por FROM ProductOrder por JOIN FETCH por.relatedParty rp ORDER BY por.orderDate DESC") + List findAllOptimized(); + + + + @Query("SELECT por FROM ProductOrder por JOIN FETCH por.note an " + + "WHERE por.uuid = ?1 " + + "ORDER BY an.date ASC") + Optional 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 0000000..bc21350 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java @@ -0,0 +1,257 @@ +/*- + * ========================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.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +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.service.Note; +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.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.ProductOrderMapper; +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.rpm685.model.ResourcePoolMapper; +import org.etsi.osl.tmf.so641.api.NotFoundException; +import org.etsi.osl.tmf.so641.model.ServiceOrder; +import org.etsi.osl.tmf.so641.model.ServiceOrderStateType; +import org.hibernate.SessionFactory; +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.EntityManagerFactory; +import jakarta.validation.Valid; + +@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; + + + private SessionFactory sessionFactory; + + + @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); + } + + + public List findAll() { + + // return (List) this.productOrderRepo.findAll(); + // return (List) this.productOrderRepo.findByOrderByOrderDateDesc(); + return (List) this.productOrderRepo.findAllOptimized(); + } + + + public List findAllParams(Map 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) this.productOrderRepo.findByState(state); + }else { + return findAll(); + } + } + + + public String findAllParamsJsonOrderIDs(Map allParams) throws JsonProcessingException { + List lso = findAllParams(allParams); + ArrayList 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; + } + + + @Transactional + public ProductOrder addProductOrder(@Valid ProductOrderCreate productOrderCreate) throws NotFoundException { + + // Ensure that all Product Specifications exist + List 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()); + } + + + + + 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; + boolean expectedCompletionDateChanged = false; + + ProductOrderMapper mapper = Mappers.getMapper( ProductOrderMapper.class ); + po = mapper.updateProductOrder(po, prodOrderUpd); + if ( prodOrderUpd.getState()!= null ) { + stateChanged = po.getState() != prodOrderUpd.getState(); + if ( po.getState().equals( ProductOrderStateType.COMPLETED )) { + po.setCompletionDate( OffsetDateTime.now(ZoneOffset.UTC)); + } + } + + if ( prodOrderUpd.getExpectedCompletionDate()!= null ) { + expectedCompletionDateChanged = true; + } + + + po = this.productOrderRepo.save(po); + + return po; + + } + + + private ProductOrder findByUuid(String id) { + Optional optionalCat = this.productOrderRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + + @Transactional + private void raisePOCreateNotification(ProductOrder so) { + + + + } + + + + +} 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 0000000..ac1b1db --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java @@ -0,0 +1,365 @@ +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.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 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.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.annotation.Transactional; +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; + + @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 params = new HashMap<>(); + params.put("state", state); + + List 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 paramsEmpty = new HashMap<>(); + List 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 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 = createProductOrder(); + ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); + String poId = responsesProductOrder.getId(); + + ProductOrderUpdate prodOrderUpd = new ProductOrderUpdate(); + prodOrderUpd.setExpectedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + Note en = new Note(); + en.text("test note2"); + prodOrderUpd.addNoteItem(en); + prodOrderUpd.addProductOrderItemItem((new ArrayList<>(responsesProductOrder.getProductOrderItem())).get(0)); + 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()); + + ProductOrder responseSOUpd = productOrderRepoService.updateProductOrder(poId, prodOrderUpd); + assertThat(responseSOUpd.getState().toString()).isEqualTo("COMPLETED"); + assertThat(responseSOUpd.getDescription()).isEqualTo("New Test Description"); + assertThat(productOrderRepoService.findAll().size()).isEqualTo(1); + assertThat( responseSOUpd.getNote().size() ).isEqualTo(2); + assertThat( responseSOUpd.getRelatedParty().size() ).isEqualTo(1); + assertThat( responseSOUpd.getProductOrderItem().size() ).isEqualTo(1); + + prodOrderUpd = new ProductOrderUpdate(); + 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(3); + 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 Service Order"); +// assertThat(eagerProductOrder.getCategory()).isEqualTo("Test Category"); +// assertThat(eagerProductOrder.getId()).isEqualTo(soId); +// } +// +// +//// // This test causes "HikariPool-1 - Connection is not available, request timed out after 30000ms" error for other tests +//// @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) +//// @Test +//// public void testAddProductOrderReturnEager() throws Exception { +//// +//// ProductOrderCreate productOrder = new ProductOrderCreate(); +//// productOrder.setCategory("Test Category"); +//// productOrder.setDescription("A Test Service Order"); +//// productOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); +//// productOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); +//// +//// Note noteItem = new Note(); +//// noteItem.text("Test note"); +//// productOrder.addNoteItem(noteItem); +//// +//// ProductOrderItem soi = new ProductOrderItem(); +//// productOrder.getOrderItem().add(soi); +//// soi.setState(ProductOrderStateType.ACKNOWLEDGED); +//// +//// +//// String eager = productOrderRepoService.addProductOrderReturnEager(productOrder); +//// ProductOrder eagerProductOrder = JsonUtils.toJsonObj(eager, ProductOrder.class); +//// assertThat(eagerProductOrder.getDescription()).isEqualTo("A Test Service Order"); +//// assertThat(eagerProductOrder.getCategory()).isEqualTo("Test Category"); +//// } +// +// +// @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 productOrderItemSet = responsesProductOrder.getOrderItem(); +// +// for (ProductOrderItem soi: productOrderItemSet) { +// String responseGraph = productOrderRepoService.getImageProductOrderItemRelationshipGraph(soId, soi.getId()); +// assertThat( responseGraph ).isNotNull(); +// } +// } + + + 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; + } +} -- GitLab From 6d270139140966aef654c13531f27c44513a1994 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 9 Aug 2024 13:12:11 +0300 Subject: [PATCH 02/59] fixing tests --- .../osl/tmf/po622/api/ProductOrderApi.java | 55 +- .../po622/api/ProductOrderApiController.java | 249 +++++--- .../api/ProductOrderApiRouteBuilder.java | 101 ++++ .../ProductOrderApiRouteBuilderEvents.java | 108 ++++ .../po622/repo/ProductOrderRepository.java | 1 + .../reposervices/ProductOrderRepoService.java | 454 +++++++++++++- .../so641/api/ServiceOrderApiController.java | 2 +- .../reposervices/ServiceOrderRepoService.java | 20 +- src/main/resources/application-testing.yml | 12 + src/main/resources/application.yml | 13 + .../po622/ProductOrderRepoServiceTest.java | 553 ++++++++++-------- src/test/resources/productorder.json | 235 ++++++++ 12 files changed, 1441 insertions(+), 362 deletions(-) create mode 100644 src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilder.java create mode 100644 src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiRouteBuilderEvents.java create mode 100644 src/test/resources/productorder.json 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 10da8d5..bd68031 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 @@ -26,6 +26,7 @@ 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; @@ -36,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; @@ -111,7 +113,7 @@ public interface ProductOrderApi { @RequestMapping(value = "/productOrder/{id}", produces = { "application/json;charset=utf-8" }, method = RequestMethod.DELETE) - default ResponseEntity deleteProductOrder(@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id + default ResponseEntity deleteProductOrder(Principal principal,@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id ) { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { } else { @@ -134,9 +136,11 @@ public interface ProductOrderApi { @RequestMapping(value = "/productOrder", produces = { "application/json;charset=utf-8" }, method = RequestMethod.GET) - default ResponseEntity> listProductOrder(@Parameter(description = "Comma-separated properties to be provided in response") @Valid @RequestParam(value = "fields", required = false) String fields + default ResponseEntity> 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")) { @@ -168,7 +172,7 @@ public interface ProductOrderApi { produces = { "application/json;charset=utf-8" }, consumes = { "application/json;charset=utf-8" }, method = RequestMethod.PATCH) - default ResponseEntity patchProductOrder(@Parameter(description = "The ProductOrder to be updated" ,required=true ) @Valid @RequestBody ProductOrderUpdate body + default ResponseEntity 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()) { @@ -200,7 +204,7 @@ public interface ProductOrderApi { @RequestMapping(value = "/productOrder/{id}", produces = { "application/json;charset=utf-8" }, method = RequestMethod.GET) - default ResponseEntity retrieveProductOrder(@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id + default ResponseEntity 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()) { @@ -217,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 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 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 4414d2f..e051726 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,21 +19,32 @@ */ 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; @@ -42,91 +53,177 @@ import org.springframework.web.bind.annotation.RequestMapping; import io.swagger.v3.oas.annotations.Parameter; import jakarta.servlet.http.HttpServletRequest; 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]") + +@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; - + private final HttpServletRequest request; - - @Autowired - ProductOrderRepoService productOrderRepoService; - @org.springframework.beans.factory.annotation.Autowired - public ProductOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = 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 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 ); - @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) - @Override - public ResponseEntity 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 { - - } - - - - - - - ProductOrder c = productOrderRepoService.addProductOrder(productOrder); - - return new ResponseEntity(c, HttpStatus.OK); - - - } catch (NotFoundException e) { - log.error("Couldn't create Service Order. ", e); - return new ResponseEntity(HttpStatus.BAD_REQUEST); - } catch (Exception e) { - log.error("Couldn't serialize response for content type application/json", e); - return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + 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 { + + } + + + + ProductOrder c = productOrderRepoService.addProductOrder(productOrder); + + return new ResponseEntity(c, HttpStatus.OK); + + + } catch (NotFoundException e) { + log.error("Couldn't create Service Order. ", e); + return new ResponseEntity(HttpStatus.BAD_REQUEST); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')") + public ResponseEntity deleteProductOrder(Principal principal, String id) { + + try { + return new ResponseEntity(productOrderRepoService.deleteByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @Override + public ResponseEntity> 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>( + productOrderRepoService.findAll(fields, new HashMap<>(), starttime, endtime), + HttpStatus.OK); + } else { + return new ResponseEntity>( + productOrderRepoService.findAll(principal.getName(), UserPartRoleType.REQUESTER), + HttpStatus.OK); + } + + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); } + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + public ResponseEntity patchProductOrder(Principal principal, + @Valid ProductOrderUpdate body, String id) { + ProductOrder c = productOrderRepoService.updateProductOrder(id, body); + + return new ResponseEntity(c, HttpStatus.OK); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + public ResponseEntity retrieveProductOrder(Principal principal, String id, + @Valid String fields) { + try { + + return new ResponseEntity( productOrderRepoService.findByUuid( id ), HttpStatus.OK); + } catch ( Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')") + public ResponseEntity 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 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 0000000..23dbc57 --- /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 0000000..8343d3d --- /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 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 index 0569c0c..ae19cea 100644 --- a/src/main/java/org/etsi/osl/tmf/po622/repo/ProductOrderRepository.java +++ b/src/main/java/org/etsi/osl/tmf/po622/repo/ProductOrderRepository.java @@ -35,6 +35,7 @@ public interface ProductOrderRepository extends CrudRepository findByUuid(String id); + Iterable 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 findByRolenameAndRoleType(String rolename, UserPartRoleType requester); 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 index bc21350..b405f63 100644 --- a/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java @@ -19,43 +19,71 @@ */ 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.rpm685.model.ResourcePoolMapper; +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.model.ServiceOrder; -import org.etsi.osl.tmf.so641.model.ServiceOrderStateType; +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 { @@ -75,10 +103,18 @@ public class ProductOrderRepoService { @Autowired ProductOfferingRepoService productOfferingRepoService; + + + @Autowired + ProductOrderApiRouteBuilderEvents productOrderApiRouteBuilder; + + @Autowired + ServiceRepoService serviceRepoService; private SessionFactory sessionFactory; + @PersistenceContext EntityManager entityManager; @Autowired public ProductOrderRepoService(EntityManagerFactory factory) { @@ -89,12 +125,25 @@ public class ProductOrderRepoService { } + @Transactional public List findAll() { // return (List) this.productOrderRepo.findAll(); // return (List) this.productOrderRepo.findByOrderByOrderDateDesc(); return (List) this.productOrderRepo.findAllOptimized(); } + + public Void deleteByUuid(String id) { + + Optional optso = this.productOrderRepo.findByUuid(id); + ProductOrder so = optso.get(); + if ( so == null ) { + return null; + } + + this.productOrderRepo.delete(so); + return null; +} public List findAllParams(Map allParams) { @@ -110,6 +159,7 @@ public class ProductOrderRepoService { public String findAllParamsJsonOrderIDs(Map allParams) throws JsonProcessingException { + List lso = findAllParams(allParams); ArrayList oids = new ArrayList<>(); for (ProductOrder object : lso) { @@ -123,6 +173,144 @@ public class ProductOrderRepoService { 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 allParams, @Valid Date starttime, @Valid Date endtime) + throws UnsupportedEncodingException { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List 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 sor " + + "JOIN sor.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 mapaEntity = query + .setResultTransformer( new ResultTransformer() { + + @Override + public Object transformTuple(Object[] tuple, String[] aliases) { + Map result = new LinkedHashMap(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() ) ; + } + ArrayList< Object> rpList = (ArrayList< Object>) result.get( "relatedParty" ); + LinkedHashMap rp = new LinkedHashMap(); + 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 findAll(String rolename, UserPartRoleType requester) { + return (List) this.productOrderRepo.findByRolename(rolename); + } @Transactional @@ -201,8 +389,11 @@ public class ProductOrderRepoService { so.addNoteItem(noteItem); so = this.productOrderRepo.save(so); + } + + raisePOCreateNotification(so); return so; @@ -214,31 +405,73 @@ public class ProductOrderRepoService { 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 ) { - stateChanged = po.getState() != prodOrderUpd.getState(); - if ( po.getState().equals( ProductOrderStateType.COMPLETED )) { - po.setCompletionDate( OffsetDateTime.now(ZoneOffset.UTC)); - } + + + 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 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; } - - private ProductOrder findByUuid(String id) { + + @Transactional + public ProductOrder findByUuid(String id) { Optional optionalCat = this.productOrderRepo.findByUuid(id); return optionalCat.orElse(null); } @@ -247,10 +480,211 @@ public class ProductOrderRepoService { @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()); + + } + + + 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() ); + for (ProductOrderItem soi : s.getProductOrderItem()) { + Hibernate.initialize( soi.getProduct().getProductCharacteristic() ); + Hibernate.initialize( soi.getProductOffering() ); + } + + tx.commit(); + } finally { + session.close(); + } + + return s; + } catch (Exception e) { + // TODO: handle exception + } + + session.close(); + return null; + + +} + + 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 boxes = new ArrayList(); + } + + Map lanes = new HashMap<>(); + String charvalue = ""; + Optional optionalCat = this.productOrderRepo.findNotesOfProdOrder(id); + if ( optionalCat.isPresent() ) { + + ProductOrder so = optionalCat.get(); + List 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/so641/api/ServiceOrderApiController.java b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiController.java index 60b5182..a83e78c 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 deleteServiceOrder( Principal principal, 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 06864b4..c761b52 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; @@ -538,9 +539,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 +548,6 @@ public class ServiceOrderRepoService { so.setCompletionDate( OffsetDateTime.now(ZoneOffset.UTC)); } - - - - - - } if ( serviceOrderUpd.getCategory()!= null ) { so.setCategory(serviceOrderUpd.getCategory()); @@ -654,9 +647,12 @@ 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); } } diff --git a/src/main/resources/application-testing.yml b/src/main/resources/application-testing.yml index b9e89cc..2efb62e 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -105,6 +105,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" +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" + #ALARMS ALARMS_ADD_ALARM: "jms:queue:ALARMS.ADD.ALARM" ALARMS_UPDATE_ALARM: "jms:queue:ALARMS.UPDATE.ALARM" @@ -127,6 +134,11 @@ 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_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" GET_USER_BY_USERNAME: "direct:get_user_byusername" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fb8fddc..4a71727 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -135,6 +135,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" +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" + + #ALARMS ALARMS_ADD_ALARM: "jms:queue:ALARMS.ADD.ALARM" ALARMS_UPDATE_ALARM: "jms:queue:ALARMS.UPDATE.ALARM" @@ -157,6 +165,11 @@ 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_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" 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 index ac1b1db..f8ea9bf 100644 --- a/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java @@ -8,6 +8,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. 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; @@ -15,6 +16,7 @@ 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; @@ -45,6 +47,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; @@ -55,311 +58,345 @@ 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 +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, + classes = OpenAPISpringBoot.class) +@AutoConfigureTestDatabase //this automatically uses h2 @AutoConfigureMockMvc @ActiveProfiles("testing") public class ProductOrderRepoServiceTest { - @Autowired - private MockMvc mvc; + @Autowired + private MockMvc mvc; - @Autowired - ProductOrderRepoService productOrderRepoService; + @Autowired + ProductOrderRepoService productOrderRepoService; - @Autowired - ProductCatalogRepoService catalogRepoService; + @Autowired + ProductCatalogRepoService catalogRepoService; - @Autowired - ProductCategoryRepoService categRepoService; + @Autowired + ProductCategoryRepoService categRepoService; - @Autowired - ProductOfferingRepoService productOfferingRepoService; - + @Autowired + ProductOfferingRepoService productOfferingRepoService; - @Autowired - ProductOfferingPriceRepoService productOfferingPriceRepoService; + @Autowired + ProductOfferingPriceRepoService productOfferingPriceRepoService; - @Autowired - ProductSpecificationRepoService productSpecificationRepoService; - - @Autowired - private WebApplicationContext context; + @Autowired + ProductSpecificationRepoService productSpecificationRepoService; - @Before - public void setup() throws Exception { - mvc = MockMvcBuilders - .webAppContextSetup(context) - .apply(springSecurity()) - .build(); - } - + @Autowired + private WebApplicationContext context; + - @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 params = new HashMap<>(); - params.put("state", state); - - List 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 paramsEmpty = new HashMap<>(); - List 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()); - } + @Autowired + TransactionTemplate txTemplate; - @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test - public void testFindAllParamsJsonOrderIDs() throws Exception { + @Before + public void setup() throws Exception { + mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } - 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(); + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testFindAllParams() throws Exception { - String state = responsesProductOrder.getState().toString(); - Map params = new HashMap<>(); - params.put("state", state); + String response = createProductOrder(); - String soIds = productOrderRepoService.findAllParamsJsonOrderIDs(params); - assertThat(soIds).contains(soId); - assertThat(soIds).contains(soId2); - } + ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); + String soId = responsesProductOrder.getId(); + String state = responsesProductOrder.getState().toString(); + // Test with not null params + Map params = new HashMap<>(); + params.put("state", state); - @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test - public void testUpdateProductOrder() throws Exception { - - assertThat( productOrderRepoService.findAll().size() ).isEqualTo( 0 ); - String response = createProductOrder(); - ProductOrder responsesProductOrder = JsonUtils.toJsonObj(response, ProductOrder.class); - String poId = responsesProductOrder.getId(); - - ProductOrderUpdate prodOrderUpd = new ProductOrderUpdate(); - prodOrderUpd.setExpectedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); - Note en = new Note(); - en.text("test note2"); - prodOrderUpd.addNoteItem(en); - prodOrderUpd.addProductOrderItemItem((new ArrayList<>(responsesProductOrder.getProductOrderItem())).get(0)); - 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()); - - ProductOrder responseSOUpd = productOrderRepoService.updateProductOrder(poId, prodOrderUpd); - assertThat(responseSOUpd.getState().toString()).isEqualTo("COMPLETED"); - assertThat(responseSOUpd.getDescription()).isEqualTo("New Test Description"); - assertThat(productOrderRepoService.findAll().size()).isEqualTo(1); - assertThat( responseSOUpd.getNote().size() ).isEqualTo(2); - assertThat( responseSOUpd.getRelatedParty().size() ).isEqualTo(1); - assertThat( responseSOUpd.getProductOrderItem().size() ).isEqualTo(1); - - prodOrderUpd = new ProductOrderUpdate(); - 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(3); - assertThat( responseSOUpd.getRelatedParty().size() ).isEqualTo(2); - - + List 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 paramsEmpty = new HashMap<>(); + List 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 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 Service Order"); -// assertThat(eagerProductOrder.getCategory()).isEqualTo("Test Category"); -// assertThat(eagerProductOrder.getId()).isEqualTo(soId); -// } -// -// -//// // This test causes "HikariPool-1 - Connection is not available, request timed out after 30000ms" error for other tests -//// @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) -//// @Test -//// public void testAddProductOrderReturnEager() throws Exception { -//// -//// ProductOrderCreate productOrder = new ProductOrderCreate(); -//// productOrder.setCategory("Test Category"); -//// productOrder.setDescription("A Test Service Order"); -//// productOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); -//// productOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); -//// -//// Note noteItem = new Note(); -//// noteItem.text("Test note"); -//// productOrder.addNoteItem(noteItem); -//// -//// ProductOrderItem soi = new ProductOrderItem(); -//// productOrder.getOrderItem().add(soi); -//// soi.setState(ProductOrderStateType.ACKNOWLEDGED); -//// -//// -//// String eager = productOrderRepoService.addProductOrderReturnEager(productOrder); -//// ProductOrder eagerProductOrder = JsonUtils.toJsonObj(eager, ProductOrder.class); -//// assertThat(eagerProductOrder.getDescription()).isEqualTo("A Test Service Order"); -//// assertThat(eagerProductOrder.getCategory()).isEqualTo("Test Category"); -//// } -// -// -// @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 productOrderItemSet = responsesProductOrder.getOrderItem(); -// -// for (ProductOrderItem soi: productOrderItemSet) { -// String responseGraph = productOrderRepoService.getImageProductOrderItemRelationshipGraph(soId, soi.getId()); -// assertThat( responseGraph ).isNotNull(); -// } -// } - - - 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 ); - - + @WithMockUser(username = "osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testFindAllParamsJsonOrderIDs() throws Exception { + String response = createProductOrder(); + String response2 = createProductOrder(); - 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()); - + 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 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; - 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()); + } 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); - - - - 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(); + 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); - - 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; + @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); + } - 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; + @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 productOrderItemSet = responsesProductOrder.getProductOrderItem(); + + for (ProductOrderItem soi : productOrderItemSet) { + String responseGraph = + productOrderRepoService.getImageProductOrderItemRelationshipGraph(soId, soi.getId()); + assertThat(responseGraph).isNotNull(); } + } + + + 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; + } } diff --git a/src/test/resources/productorder.json b/src/test/resources/productorder.json new file mode 100644 index 0000000..c4d24ce --- /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 -- GitLab From a7917289e4ba863355e9658ce11ed710b6e8b83c Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 9 Aug 2024 20:14:33 +0300 Subject: [PATCH 03/59] adding api to create prod offer from spec --- .../tmf/pcm620/api/ProductOfferingApi.java | 20 ++++ .../api/ProductOfferingApiController.java | 16 ++++ .../ProductOfferingRepoService.java | 91 ++++++++++++++++++- .../ProductSpecificationRepoService.java | 75 ++++++++++++++- .../po622/ProductOrderRepoServiceTest.java | 53 +++++++++++ src/test/resources/testServiceSpec2.json | 29 ++++++ 6 files changed, 279 insertions(+), 5 deletions(-) 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 3b0eacf..181bde0 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 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 c22b53e..b131825 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(HttpStatus.INTERNAL_SERVER_ERROR); } } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createRetrieveProductOfferingBasedOnServiceSpec( + String id) { + try { + + + return new ResponseEntity(productOfferingRepoService.createRetrieveProductOfferingBasedOnServiceSpec(id), + HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + + } } 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 b53dd5b..422d8f2 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; @@ -320,6 +337,7 @@ public class ProductOfferingRepoService { if ( prodOfferingUpd.getProductSpecification() != null ) { prodOffering.setProductSpecification( prodOfferingUpd.getProductSpecification() ); + prodOffering = copyCharacteristicsFromProdSpec( prodOffering, prodOfferingUpd.getProductSpecification() ); } @@ -542,5 +560,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 2994b2a..b7bb5ee 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; @@ -428,7 +436,7 @@ public class ProductSpecificationRepoService { } - + /** * Update ProductSpecificationRelationship list @@ -548,7 +556,7 @@ public class ProductSpecificationRepoService { } /** - * Update ResourceSpecificationRef list + * Update ServiceSpecificationRef list */ if (prodSpecUpd.getServiceSpecification() != null) { @@ -569,6 +577,7 @@ public class ProductSpecificationRepoService { if (!idexists) { prodSpec.getServiceSpecification().add(ar); + prodSpec = copyConfigurableCharacteristics( prodSpec, ar ); idAddedUpdated.put(ar.getUuid(), true); } } @@ -597,5 +606,65 @@ 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( cnew.getName() ); + cnew.setDescription( cnew.getDescription()); + cnew.isUnique(cnew.isIsUnique()) + .extensible(cnew.isExtensible()) + .maxCardinality(cnew.getMaxCardinality()) + .minCardinality(cnew.getMinCardinality()) + .valueType(cnew.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; + } } 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 index f8ea9bf..f196c06 100644 --- a/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/api/po622/ProductOrderRepoServiceTest.java @@ -309,6 +309,36 @@ public class ProductOrderRepoServiceTest { 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 { @@ -399,4 +429,27 @@ public class ProductOrderRepoServiceTest { 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/resources/testServiceSpec2.json b/src/test/resources/testServiceSpec2.json index 13e648d..987a2cc 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" + } + } + ] } ] } -- GitLab From ef36e67ccf5e4edecbfbadd24e0cd8361aba0425 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 17 Aug 2024 01:09:12 +0300 Subject: [PATCH 04/59] update product order api --- .../ProductSpecificationApiRouteBuilder.java | 95 +++++++++++++++++++ .../ProductOfferingRepoService.java | 3 + .../ProductSpecificationRepoService.java | 31 ++++-- .../po622/api/ProductOrderApiController.java | 1 + .../reposervices/ProductOrderRepoService.java | 24 +++-- src/main/resources/application-testing.yml | 7 ++ src/main/resources/application.yml | 6 ++ .../api/ServiceOrderIntegrationTest.java | 4 +- 8 files changed, 154 insertions(+), 17 deletions(-) create mode 100644 src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java 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 0000000..07fe723 --- /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 422d8f2..40176d7 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 @@ -222,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()); @@ -238,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 { 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 b7bb5ee..deec0a6 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 @@ -208,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? @@ -215,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() ); } @@ -618,13 +622,13 @@ public class ProductSpecificationRepoService { if ( prodSpec.findProdCharacteristicByName( ssc.getName() ) == null ) { ProductSpecificationCharacteristic cnew = new ProductSpecificationCharacteristic(); - cnew.setName( cnew.getName() ); - cnew.setDescription( cnew.getDescription()); - cnew.isUnique(cnew.isIsUnique()) - .extensible(cnew.isExtensible()) - .maxCardinality(cnew.getMaxCardinality()) - .minCardinality(cnew.getMinCardinality()) - .valueType(cnew.getValueType()); + 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()) @@ -666,5 +670,14 @@ public class ProductSpecificationRepoService { 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/po622/api/ProductOrderApiController.java b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiController.java index e051726..ab307dd 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 @@ -147,6 +147,7 @@ public class ProductOrderApiController implements ProductOrderApi { } @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')") public ResponseEntity> listProductOrder(Principal principal, @Valid String fields, @Valid Integer offset, @Valid Integer limit, @Valid Date starttime, @Valid Date endtime) { 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 index b405f63..c572a65 100644 --- a/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java @@ -67,6 +67,7 @@ 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; @@ -112,6 +113,9 @@ public class ProductOrderRepoService { @Autowired ServiceRepoService serviceRepoService; + @Autowired + ServiceOrderRepoService serviceOrderRepoService; + private SessionFactory sessionFactory; @PersistenceContext EntityManager entityManager; @@ -222,8 +226,8 @@ public class ProductOrderRepoService { } } - sql += " FROM ProductOrder sor " - + "JOIN sor.relatedParty rp "; + sql += " FROM ProductOrder por " + + "JOIN por.relatedParty rp "; if (allParams.size() > 0) { sql += " WHERE rp.role = 'REQUESTER' AND "; @@ -353,6 +357,10 @@ public class ProductOrderRepoService { so.getNote().addAll(productOrderCreate.getNote()); } + so.setState( productOrderCreate.getState() ); + + + @@ -510,7 +518,7 @@ public class ProductOrderRepoService { } - + @Transactional public ProductOrder getProductOrderEager(String id) { Session session = sessionFactory.openSession(); @@ -527,9 +535,12 @@ public class ProductOrderRepoService { Hibernate.initialize(s.getRelatedParty()); Hibernate.initialize(s.getProductOrderItem() ); Hibernate.initialize(s.getNote() ); + Hibernate.initialize(s.getChannel()); for (ProductOrderItem soi : s.getProductOrderItem()) { - Hibernate.initialize( soi.getProduct().getProductCharacteristic() ); - Hibernate.initialize( soi.getProductOffering() ); + if ( soi.getProduct() != null ) { + Hibernate.initialize( soi.getProduct().getProductCharacteristic() ); + } + Hibernate.initialize( soi.getProductOffering() ); } tx.commit(); @@ -539,7 +550,7 @@ public class ProductOrderRepoService { return s; } catch (Exception e) { - // TODO: handle exception + e.printStackTrace(); } session.close(); @@ -548,6 +559,7 @@ public class ProductOrderRepoService { } + @Transactional public String getProductOrderEagerAsString(String id) throws JsonProcessingException { ProductOrder s = this.getProductOrderEager(id); ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/resources/application-testing.yml b/src/main/resources/application-testing.yml index 2efb62e..4e908f4 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -88,6 +88,13 @@ 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_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" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4a71727..db294fe 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -117,6 +117,12 @@ 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_INITIAL_SERVICEORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_SERVICEORDERS" CATALOG_GET_SERVICEORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_SERVICEORDERS" 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 017804b..142c2fa 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,7 +261,7 @@ public class ServiceOrderIntegrationTest { assertThat( responsesSpec1.getServiceSpecCharacteristic().size() ).isEqualTo( 2 ); - assertThat( responsesSpec2.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); + assertThat( responsesSpec2.getServiceSpecCharacteristic().size() ).isEqualTo( 4 ); assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); -- GitLab From 4ebbc223e5aa3144a9a46f82d1e321cf584cafce Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 17 Aug 2024 01:27:24 +0300 Subject: [PATCH 05/59] update tests --- .../osl/tmf/po622/reposervices/ProductOrderRepoService.java | 6 +++++- .../etsi/osl/services/api/ServiceOrderIntegrationTest.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) 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 index c572a65..2ae7aa0 100644 --- a/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/po622/reposervices/ProductOrderRepoService.java @@ -357,7 +357,11 @@ public class ProductOrderRepoService { so.getNote().addAll(productOrderCreate.getNote()); } - so.setState( productOrderCreate.getState() ); + if ( productOrderCreate.getState() != null ) { + so.setState( productOrderCreate.getState() ); + } else { + so.setState( ProductOrderStateType.INITIAL ); + } 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 142c2fa..b05c6e7 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java @@ -262,7 +262,7 @@ public class ServiceOrderIntegrationTest { assertThat( responsesSpec1.getServiceSpecCharacteristic().size() ).isEqualTo( 2 ); assertThat( responsesSpec2.getServiceSpecCharacteristic().size() ).isEqualTo( 4 ); - assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); + assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 4 ); responseSO.getOrderItem().stream().forEach(soiElement -> { -- GitLab From 53b0aaf3a0f1cc31b6f21c497c8bae541102934d Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Fri, 30 Aug 2024 13:54:04 +0000 Subject: [PATCH 06/59] fix: strictly compare between strings --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb7d754..40be386 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 -- GitLab From 18f6798da57597e6b3723cc6a20ff87da96d8a7c Mon Sep 17 00:00:00 2001 From: Rafael Direito Date: Sat, 7 Sep 2024 19:57:15 +0000 Subject: [PATCH 07/59] NSLCM Statuses are now being offered as an array of Json Nodes --- .../sim638/service/ServiceRepoService.java | 87 ++- .../service/ServiceRepoServiceTest.java | 60 +- .../104426_forTesting/initial_service.json | 617 +++++++++++++++++- 3 files changed, 725 insertions(+), 39 deletions(-) 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 eaf0609..58b4c91 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 @@ -32,6 +32,8 @@ import java.util.Optional; 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; @@ -760,43 +762,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 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>() {}); + // 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; } @@ -1248,7 +1279,5 @@ public class ServiceRepoService { } - - } diff --git a/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java index 255b054..fbd4718 100644 --- a/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java @@ -43,6 +43,9 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; 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) @ActiveProfiles("testing") @@ -174,7 +177,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 +229,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 +277,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 eaf9408..156e771 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 -- GitLab From d8b4a2235d781c2237e1dbe7de6a8034a29341d7 Mon Sep 17 00:00:00 2001 From: trantzas Date: Tue, 17 Sep 2024 19:20:58 +0000 Subject: [PATCH 08/59] Development preparation for release 2024Q4 --- Dockerfile | 4 ++-- pom.xml | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e7a7b05..a192566 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-SNAPSHOT-exec.jar /opt/openslice/lib/ +CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.tmf.api-1.1.0-SNAPSHOT-exec.jar"] EXPOSE 13082 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 885c306..51dad97 100644 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,19 @@ org.etsi.osl org.etsi.osl.main - 1.0.0 + 2024Q4-SNAPSHOT ../org.etsi.osl.main org.etsi.osl.tmf.api org.etsi.osl.tmf.api + ${org.etsi.osl.tmf.api.version} + + + OpenSlice by ETSI + https://osl.etsi.org + -- GitLab From e313f093a20f2d1f18ecc8847ebd9c908be7a65a Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Thu, 24 Oct 2024 15:21:41 +0300 Subject: [PATCH 09/59] fix for #47 --- .../org/etsi/osl/tmf/BootstrapResources.java | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/etsi/osl/tmf/BootstrapResources.java b/src/main/java/org/etsi/osl/tmf/BootstrapResources.java index dacfb02..9fdf7d7 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 ); + } } -- GitLab From 672eedfc22a2e9162a6d234c6d3a366b2864a2ed Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 25 Oct 2024 20:15:51 +0300 Subject: [PATCH 10/59] fix for #48 --- .../rcm634/api/ResourceSpecificationApiRouteBuilder.java | 8 ++++---- src/main/resources/application-testing.yml | 2 +- src/main/resources/application.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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 59e04ea..79b2f43 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/resources/application-testing.yml b/src/main/resources/application-testing.yml index b9e89cc..f237167 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -140,7 +140,7 @@ 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" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fb8fddc..6028f7f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -172,7 +172,7 @@ 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" -- GitLab From 43823766a949c73fe4aa727df42736e7fc41bcc3 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Wed, 30 Oct 2024 17:50:28 +0200 Subject: [PATCH 11/59] Added @AutoConfigureTestDatabase to isolate each test suite's bootstrapped resources --- .../etsi/osl/services/api/ResourceOrderIntegrationTest.java | 1 - .../etsi/osl/services/api/ServiceCatalogIntegrationTest.java | 4 +++- .../api/scm633/ServiceSpecificationApiControllerTest.java | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) 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 592b6e4..2a60d58 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 511e46c..807e356 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 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/scm633/ServiceSpecificationApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java index e5aa51e..dea6f82 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 { -- GitLab From 6029af03d1301b3d9662a901769304446d3dbcad Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 4 Nov 2024 13:34:56 +0200 Subject: [PATCH 12/59] After updating the model 2 new Logical Sprecs were added for bootstraping and tests were not updated Now ResourceCatalogIntegrationTest is paasing all tests --- .../etsi/osl/services/api/ResourceCatalogIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 02aa8e0..1d28768 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; -- GitLab From 17c95d2ef67a2cc99b83cf93759f5c298d783279 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 4 Nov 2024 13:45:46 +0200 Subject: [PATCH 13/59] After updating the model 2 new Logical Sprecs were added for bootstraping and tests were not updated Now ResourceSpecificationApiControllerTest is paasing all tests --- .../api/rcm634/ResourceSpecificationApiControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1aa8d1a..5dc588e 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 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) -- GitLab From 09df170e6152ffad93da2e36f54e0c403fe392c6 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 4 Nov 2024 16:55:32 +0200 Subject: [PATCH 14/59] added @AutoConfigureTestDatabase --- .../osl/services/api/ResourceInventoryIntegrationTest.java | 3 ++- .../etsi/osl/services/api/ri639/ResourceApiControllerTest.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 ee4d7a4..fd6989e 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( 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 9e2f8df..408ce1f 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 { -- GitLab From 62d355f346798df4f97671671982a06a3ebffc5e Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Tue, 5 Nov 2024 23:54:22 +0200 Subject: [PATCH 15/59] fix for #50 --- .../reposervices/ResourceRepoService.java | 6 + .../sim638/api/ServiceApiRouteBuilder.java | 26 ++-- .../sim638/service/ServiceRepoService.java | 4 +- .../api/sim638/ServiceRepoServiceTest.java | 135 +++++++++++++----- 4 files changed, 120 insertions(+), 51 deletions(-) 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 9e79d47..7f52235 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,6 +60,7 @@ 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; @@ -91,6 +92,9 @@ public class ResourceRepoService { @Autowired ResourceApiRouteBuilderEvents resourceApiRouteBuilder; + + @Autowired + ServiceRepoService serviceRepoService; @Autowired public ResourceRepoService(EntityManagerFactory factory) { @@ -445,6 +449,8 @@ public class ResourceRepoService { resource = this.resourceRepo.save(resource); + this.serviceRepoService.updateServicesHavingThisSupportingResource(resource); + if (resourceCharacteristicChanged) { raiseResourceAttributeValueChangeEventNotification(resource); } else if (resourceStateChanged) { 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 93afc97..b1e6877 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 @@ -224,19 +224,19 @@ public class ServiceApiRouteBuilder extends RouteBuilder { - from( EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED ) - .errorHandler(deadLetterChannel("direct:retriesDeadLetters") - .maximumRedeliveries(5) - .redeliveryDelay(1000).useOriginalMessage() - .logExhausted(true) - .logHandled(true) - .retriesExhaustedLogLevel(LoggingLevel.ERROR) - .retryAttemptedLogLevel(LoggingLevel.ERROR)) - - .log(LoggingLevel.INFO, 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})"); +// from( EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED ) +// .errorHandler(deadLetterChannel("direct:retriesDeadLetters") +// .maximumRedeliveries(5) +// .redeliveryDelay(1000).useOriginalMessage() +// .logExhausted(true) +// .logHandled(true) +// .retriesExhaustedLogLevel(LoggingLevel.ERROR) +// .retryAttemptedLogLevel(LoggingLevel.ERROR)) +// +// .log(LoggingLevel.INFO, 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/service/ServiceRepoService.java b/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java index 58b4c91..436cb6c 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 @@ -1111,11 +1111,9 @@ 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() ); var aservices = findServicesHavingThisSupportingResourceID( res.getId() ); 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 7b6b52c..d011129 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; @@ -69,6 +69,7 @@ public class ServiceRepoServiceTest { @Autowired ServiceRepoService serviceRepoService; + @Autowired ResourceRepoService resourceRepoService; @@ -230,42 +231,106 @@ 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 resourceRefSet = responsesService.getSupportingResource(); -// List 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 noteSet = updatedService.getNote(); -// List 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 resourceRefSet = responsesService.getSupportingResource(); + List 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 noteSet = updatedService.getNote(); + List 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 testResourceAttrChangedEvent() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + Set resourceRefSet = responsesService.getSupportingResource(); + List 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 ); + + + + @Valid ResourceAttributeValueChangeNotification resNotid = new ResourceAttributeValueChangeNotification(); + ResourceAttributeValueChangeEvent event = new ResourceAttributeValueChangeEvent(); + event.getEvent().setResource(resource); + + resNotid.setEvent( event ); + + Service updatedService = serviceRepoService.findByUuid(id); + + assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 6 ); + assertThat( updatedService.getSupportingResource().size() ).isEqualTo( 1); + + ResourceUpdate resourceUpdate = new ResourceUpdate(); + + org.etsi.osl.tmf.ri639.model.Characteristic 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()); + assertThat( resource.getResourceCharacteristic().size() ).isEqualTo( 1 ); + + Thread.sleep(1000); + + System.out.println("STEP 3 - =========================================== " ); + updatedService = serviceRepoService.findByUuid(id); + assertThat( updatedService.getSupportingResource().size() ).isEqualTo( 1); + assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 7 ); + + Set noteSet = updatedService.getNote(); + List noteList = new ArrayList<>(noteSet); + + boolean expectedNoteExists = false; + for (Note n : noteList) { + if ( n.getText().contains("Service Characteristic changed") && n.getAuthor().equals("API")) { + expectedNoteExists= true; + break; + } + } + assertThat( expectedNoteExists ).isTrue(); + } + + + @Transactional private String createService() throws Exception { int servicesCount = serviceRepoService.findAll().size(); -- GitLab From a0d6b621de5113ad5c082a6c80a93ae488e02817 Mon Sep 17 00:00:00 2001 From: Eduardo Santos Date: Wed, 6 Nov 2024 20:52:27 +0000 Subject: [PATCH 16/59] Implemented and tested TMF702 API --- pom.xml | 6 + .../etsi/osl/tmf/ram702/api/ApiException.java | 29 + .../osl/tmf/ram702/api/ApiOriginFilter.java | 50 ++ .../tmf/ram702/api/ApiResponseMessage.java | 88 +++ .../osl/tmf/ram702/api/NotFoundException.java | 29 + .../tmf/ram702/api/ResourceActivationApi.java | 317 ++++++++++ .../api/ResourceActivationApiController.java | 241 ++++++++ .../ResourceActivationApiRouteBuilder.java | 102 ++++ ...sourceActivationApiRouteBuilderEvents.java | 112 ++++ .../ram702/api/ResourceNotFoundException.java | 8 + .../repo/ResourceActivationRepository.java | 57 ++ .../tmf/ram702/repo/ResourceRepository.java | 63 ++ .../ResourceActivationRepoService.java | 564 ++++++++++++++++++ .../tmf/ram702/utils/JSONResponseUtils.java | 361 +++++++++++ .../ri639/api/ResourceApiRouteBuilder.java | 44 +- .../ResourceActivationRepoServiceTest.java | 418 +++++++++++++ .../reposervices/ram702/resource.json | 61 ++ .../reposervices/ram702/resourceCreate.json | 35 ++ 18 files changed, 2563 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ApiException.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ApiOriginFilter.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ApiResponseMessage.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/NotFoundException.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilderEvents.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ResourceNotFoundException.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceActivationRepository.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java create mode 100644 src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java create mode 100644 src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java create mode 100644 src/test/resources/reposervices/ram702/resource.json create mode 100644 src/test/resources/reposervices/ram702/resourceCreate.json diff --git a/pom.xml b/pom.xml index 51dad97..97de096 100644 --- a/pom.xml +++ b/pom.xml @@ -295,6 +295,12 @@ junit-platform-runner test + + org.mockito + mockito-inline + 4.0.0 + test + com.h2database h2 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 0000000..c4fa93b --- /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 0000000..e1e9261 --- /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 0000000..8b8bfb8 --- /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 0000000..92eaec8 --- /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 0000000..da9b4e7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApi.java @@ -0,0 +1,317 @@ +/*- + * ========================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; + +import org.etsi.osl.tmf.ram702.utils.JSONResponseUtils; + +@Tag(name = "resource", description = "The resource Activation API") +public interface ResourceActivationApi { + + Logger log = LoggerFactory.getLogger(ResourceActivationApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional 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 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( + JSONResponseUtils.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 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> 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 allParams + ) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>( + getObjectMapper().get().readValue( + JSONResponseUtils.RESOURCE_LIST_JSON_RESPONSE, + new TypeReference>() {} + ), + 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 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( + JSONResponseUtils.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 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( + JSONResponseUtils.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 0000000..5421344 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java @@ -0,0 +1,241 @@ +/*- + * ========================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.ram702.reposervices.ResourceActivationRepoService; + +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("/resourceActivationManagement/v4/") +public class ResourceActivationApiController implements ResourceActivationApi { + + private final ObjectMapper objectMapper; + private final HttpServletRequest request; + + @Autowired + private ResourceActivationRepoService 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 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.CREATED); + } 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 deleteResource(String id) { + try { + resourceRepoService.deleteByUuid(id); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } catch (ApiException e) { + log.error("Resource not found with id {}", id); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); // 404 if resource not found + } catch (Exception e) { + log.error("Error deleting resource with id {}", id, e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); // 500 for any other errors + } + } + + + /** + * 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> listResource( + Principal principal, + @Valid String fields, + @Valid Integer offset, + @Valid Integer limit, + Map allParams + ) { + try { + List 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 patchResource( + Principal principal, + @Valid ResourceUpdate resource, + String id + ) { + try { + // Call the updateResource method from the service class to update the resource + Resource updatedResource = resourceRepoService.updateResource(id, resource, true); + + // Return the updated resource with 200 OK status + return new ResponseEntity<>(updatedResource, HttpStatus.OK); + + } catch (ResourceNotFoundException e) { + log.error("Resource not found with id {}", id, e); + // Return 404 Not Found if the resource is not found + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } catch (Exception e) { + log.error("Error updating resource with id {}", id, e); + // Return 500 Internal Server Error for any other unexpected exceptions + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + /** + * 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 retrieveResource( + Principal principal, + String id, + @Valid String fields + ) { + try { + // Call the service method to retrieve the resource + Resource resource = resourceRepoService.findByUuid(id); + + // Return the resource with 200 OK status + return new ResponseEntity<>(resource, HttpStatus.OK); + + } catch (ResourceNotFoundException e) { + log.error("Resource not found with id {}", id, e); + // Return 404 Not Found if the resource is not found + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + + } catch (Exception e) { + log.error("Error retrieving resource with id {}", id, e); + // Return 500 Internal Server Error for any unexpected exceptions + return new ResponseEntity<>(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 0000000..c556c8f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java @@ -0,0 +1,102 @@ +/*- + * ========================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.ram702.reposervices.ResourceActivationRepoService; + +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_RESOURCE}") + private String CATALOG_ADD_RESOURCE = ""; + + @Value("${CATALOG_UPD_RESOURCE}") + private String CATALOG_UPD_RESOURCE = ""; + + @Value("${CATALOG_UPDADD_RESOURCE}") + private String CATALOG_UPDADD_RESOURCE = ""; + + @Value("${CATALOG_GET_RESOURCE_BY_ID}") + private String CATALOG_GET_RESOURCE_BY_ID = ""; + + @Autowired + private ProducerTemplate template; + + @Autowired + ResourceActivationRepoService resourceRepoService; + + @Override + public void configure() throws Exception { + + from( CATALOG_ADD_RESOURCE ) + .log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " 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_RESOURCE ) + .log(LoggingLevel.INFO, 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} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPDADD_RESOURCE ) + .log(LoggingLevel.INFO, 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})") + .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/ResourceActivationApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilderEvents.java new file mode 100644 index 0000000..c30136f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilderEvents.java @@ -0,0 +1,112 @@ +/*- + * ========================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.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.tmf.common.model.Notification; +import org.etsi.osl.tmf.ri639.model.ResourceAttributeValueChangeNotification; +import org.etsi.osl.tmf.ri639.model.ResourceCreateNotification; +import org.etsi.osl.tmf.ri639.model.ResourceStateChangeNotification; + +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 ResourceActivationApiRouteBuilderEvents extends RouteBuilder { + + private static final transient Log logger = + LogFactory.getLog(ResourceActivationApiRouteBuilderEvents.class.getName()); + + + + @Value("${EVENT_RESOURCE_CREATE}") + private String EVENT_RESOURCE_CREATE = ""; + + @Value("${EVENT_RESOURCE_STATE_CHANGED}") + private String EVENT_RESOURCE_STATE_CHANGED = ""; + + @Value("${EVENT_RESOURCE_DELETE}") + private String EVENT_RESOURCE_DELETE = ""; + + @Value("${EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED}") + private String EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED = ""; + + + @Autowired + private ProducerTemplate template; + + + @Override + public void configure() throws Exception { + + } + + + /** + * @param n + */ + public void publishEvent(final Notification n, final String objId) { + n.setEventType(n.getClass().getName()); + logger.info("will send Event topic for type " + n.getEventType()); + try { + String msgtopic = ""; + + if (n instanceof ResourceCreateNotification) { + msgtopic = EVENT_RESOURCE_CREATE; + } else if (n instanceof ResourceAttributeValueChangeNotification) { + msgtopic = EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED; + }else if (n instanceof ResourceStateChangeNotification ) { + msgtopic = EVENT_RESOURCE_STATE_CHANGED; + } + + Map map = new HashMap<>(); + map.put("eventid", n.getEventId()); + map.put("objId", objId); + + template.sendBodyAndHeaders(msgtopic, toJsonString(n), map); + + } catch (Exception e) { + logger.error("Cannot send Event . " + e.getStackTrace()); + } + } + + 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 0000000..1f08d3e --- /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/ram702/repo/ResourceActivationRepository.java b/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceActivationRepository.java new file mode 100644 index 0000000..1cc064d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceActivationRepository.java @@ -0,0 +1,57 @@ +/*- + * ========================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.repo; + +import java.util.List; +import java.util.Optional; + +import org.etsi.osl.tmf.ri639.model.Resource; + +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("resourceActivationRepository") +public interface ResourceActivationRepository extends CrudRepository, PagingAndSortingRepository { + + Optional findByUuid(String id); + + @Query( + "SELECT srv FROM RIResource srv " + + "JOIN FETCH srv.relatedParty rp " + + "WHERE rp.name = ?1" + ) + Iterable findByRolename(String name); + + @Query( + "SELECT srv FROM RIResource srv " + + "WHERE srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.AVAILABLE " + + "AND srv.endOperatingDate < CURRENT_TIMESTAMP" + ) + List findActiveToTerminate(); + + List findByNameAndResourceVersion(String aname, String aversion); + + List findByNameAndCategoryAndResourceVersion(String aname, String acategory, String aversion); +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java b/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java new file mode 100644 index 0000000..9faab4d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java @@ -0,0 +1,63 @@ +/*- + * ========================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.repo; + +import java.util.List; +import java.util.Optional; + +import org.etsi.osl.tmf.ri639.model.Resource; + +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("resourceRepository702") +public interface ResourceRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + @Query("SELECT srv FROM RIResource srv JOIN FETCH srv.relatedParty rp WHERE rp.name = ?1") + Iterable findByRolename(String name); + + + @Query("SELECT srv FROM RIResource srv WHERE srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.AVAILABLE AND " + + "srv.endOperatingDate < CURRENT_TIMESTAMP") + List findActiveToTerminate(); + + @Query("SELECT srv FROM RIResource srv " + + "JOIN FETCH srv.resourceCharacteristic char " + + "JOIN FETCH char.value val " + + "WHERE (srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.AVAILABLE OR " + + " srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.RESERVED OR " + + " srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.STANDBY) AND " + + "char.name = 'externalPartnerServiceId'" + ) + + List findActiveAndReservedResourcesOfPartners(); + + + List findByNameAndResourceVersion(String aname, String aversion); + List findByNameAndCategoryAndResourceVersion(String aname, String acategory, String aversion); +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java b/src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java new file mode 100644 index 0000000..88d04f9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java @@ -0,0 +1,564 @@ +/*- + * ========================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.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.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +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.ram702.api.ApiException; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.ram702.api.ResourceActivationApiRouteBuilderEvents; +import org.etsi.osl.tmf.ram702.api.ResourceNotFoundException; +import org.etsi.osl.tmf.ri639.model.Characteristic; +import org.etsi.osl.tmf.ri639.model.Feature; +import org.etsi.osl.tmf.ri639.model.LogicalResource; +import org.etsi.osl.tmf.ri639.model.PhysicalResource; +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceAttributeValueChangeEvent; +import org.etsi.osl.tmf.ri639.model.ResourceAttributeValueChangeNotification; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceCreateEvent; +import org.etsi.osl.tmf.ri639.model.ResourceCreateNotification; +import org.etsi.osl.tmf.ri639.model.ResourceRelationship; +import org.etsi.osl.tmf.ri639.model.ResourceStateChangeEvent; +import org.etsi.osl.tmf.ri639.model.ResourceStateChangeNotification; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; +import org.etsi.osl.tmf.ram702.repo.ResourceActivationRepository; + +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.Transactional; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +/** + * Service class for managing Resource Activation operations. + * Provides methods to add, update, delete, and retrieve resources. + */ +@org.springframework.stereotype.Service +public class ResourceActivationRepoService { + + private static final transient Log logger = + LogFactory.getLog(ResourceActivationRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ResourceActivationRepository resourceRepo; + + @Autowired + ResourceSpecificationRepoService resourceSpecRepoService; + + private SessionFactory sessionFactory; + + @Autowired + ResourceActivationApiRouteBuilderEvents resourceApiRouteBuilder; + + + /** + * Constructs the ResourceActivationRepoService with the given EntityManagerFactory. + * + * @param factory the EntityManagerFactory to use + */ + @Autowired + public ResourceActivationRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + /** + * Retrieves all resources from the repository. + * + * @return a list of all resources + */ + public List findAll() { + + return (List) this.resourceRepo.findAll(); + } + + /** + * Finds resources by name and requester role. + * + * @param name the name of the resource + * @param requester the requester role + * @return a list of resources matching the name and requester role + */ + public List findAll(String name, UserPartRoleType requester) { + + return (List) this.resourceRepo.findByRolename(name); + } + + + /** + * Adds a new resource to the repository. + * + * @param resource the resource to add + * @return the added resource + */ + public Resource addResource(@Valid ResourceCreate resource){ + logger.info("Will add Resource: " + resource.getName()); + + Resource s; + + if (resource.getAtType() != null + && resource.getAtType().toLowerCase().contains("physicalresource")) { + s = new PhysicalResource(); + } else { + s = new LogicalResource(); + } + + if (resource.getAtType() != null) { + s.setType(resource.getAtType()); + } + s.setName(resource.getName()); + s.setCategory(resource.getCategory()); + s.setDescription(resource.getDescription()); + + if ( resource.getStartOperatingDate() == null ) { + s.setStartOperatingDate(OffsetDateTime.now(ZoneOffset.UTC)); + } else { + s.setStartOperatingDate(resource.getStartOperatingDate()); + } + s.setEndOperatingDate(resource.getEndOperatingDate()); + s.setUsageState(resource.getUsageState()); + s.setResourceStatus(resource.getResourceStatus()); + s.setResourceVersion(resource.getResourceVersion()); + s.setOperationalState(resource.getOperationalState()); + s.setAdministrativeState(resource.getAdministrativeState()); + + ResourceSpecificationRef thespecRef = new ResourceSpecificationRef(); + thespecRef.setId(resource.getResourceSpecification().getId()); + thespecRef.setName(resource.getResourceSpecification().getName()); + + s.setResourceSpecification(thespecRef); + + if (resource.getPlace() != null) { + s.setPlace(resource.getPlace()); + } + if (resource.getNote() != null) { + s.getNote().addAll(resource.getNote()); + } + if (resource.getRelatedParty() != null) { + s.getRelatedParty().addAll(resource.getRelatedParty()); + } + if (resource.getResourceCharacteristic() != null) { + s.getResourceCharacteristic().addAll(resource.getResourceCharacteristic()); + } + if (resource.getResourceRelationship() != null) { + s.getResourceRelationship().addAll(resource.getResourceRelationship()); + } + if (resource.getAttachment() != null) { + s.getAttachment().addAll(resource.getAttachment()); + } + if (resource.getActivationFeature() != null) { + s.getActivationFeature().addAll(resource.getActivationFeature()); + } + + Note noteItem = new Note(); + noteItem.setText("Resource status: " + s.getResourceStatus()); + noteItem.setAuthor("API"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC)); + s.addNoteItem(noteItem); + + s = this.resourceRepo.save(s); + + raiseResourceCreateNotification(s); + return s; + } + + + /** + * Finds a resource by its UUID. + * + * @param id the UUID of the resource + * @return the resource if found, or null if not found + */ + @Transactional + public Resource findByUuid(String id) throws ResourceNotFoundException { + Optional optionalCat = this.resourceRepo.findByUuid(id); + + if (optionalCat.isEmpty()) { + throw new ResourceNotFoundException("Resource not found with UUID: " + id); + } + + return optionalCat.get(); + } + + + /** + * Updates an existing resource with the given updates. + * + * @param id the UUID of the resource to update + * @param resourceUpd the resource update data + * @param triggerServiceActionQueue whether to trigger service action queue + * @return the updated resource + */ + @Transactional + public Resource updateResource(String id, @Valid ResourceUpdate resourceUpd, + boolean triggerServiceActionQueue) throws ResourceNotFoundException { + Resource resource = this.getResourceEager(id); + + if (resource == null) { + throw new ResourceNotFoundException("Resource not found with UUID: " + id); + } + + logger.info("Will update Resource: " + resource.getName()); + + if (resourceUpd.getResourceRelationship() != null) { + resource.setResourceRelationship( + new LinkedHashSet(resourceUpd.getResourceRelationship() + )); + } + + if (resourceUpd.getAtType() != null) { + resource.setType(resourceUpd.getAtType()); + } + if (resourceUpd.getName() != null) { + resource.setName(resourceUpd.getName()); + } + if (resourceUpd.getCategory() != null) { + resource.setCategory(resourceUpd.getCategory()); + } + if (resourceUpd.getDescription() != null) { + resource.setDescription(resourceUpd.getDescription()); + } + if (resourceUpd.getStartOperatingDate() != null) { + resource.setStartOperatingDate(resourceUpd.getStartOperatingDate()); + } + if (resourceUpd.getEndOperatingDate() != null) { + resource.setEndOperatingDate(resourceUpd.getEndOperatingDate()); + } + if (resourceUpd.getUsageState() != null) { + resource.setUsageState(resourceUpd.getUsageState()); + } + + boolean resourceStateChanged = false; + if (resourceUpd.getResourceStatus() != null) { + if (!resourceUpd.getResourceStatus().equals(resource.getResourceStatus())) { + resourceStateChanged = true; + } + + resource.setResourceStatus(resourceUpd.getResourceStatus()); + } + if (resourceUpd.getResourceVersion() != null) { + resource.setResourceVersion(resourceUpd.getResourceVersion()); + } + if (resourceUpd.getOperationalState() != null) { + resource.setOperationalState(resourceUpd.getOperationalState()); + } + if (resourceUpd.getAdministrativeState() != null) { + resource.setAdministrativeState(resourceUpd.getAdministrativeState()); + } + if (resourceUpd.getResourceSpecification() != null) { + resource.setResourceSpecification(resourceUpd.getResourceSpecification()); + } + + if (resourceUpd.getPlace() != null) { + resource.setPlace(resourceUpd.getPlace()); + } + + if (resourceUpd.getNote() != null) { + for (Note n : resourceUpd.getNote()) { + if (n.getUuid() == null) { + resource.addNoteItem(n); + } + } + } + + if (resourceUpd.getRelatedParty() != null) { + for (RelatedParty n : resourceUpd.getRelatedParty()) { + if (n.getUuid() == null) { + resource.addRelatedPartyItem(n); + } + } + } + + boolean resourceCharacteristicChanged = false; + String charsChanged=""; + if (resourceUpd.getResourceCharacteristic() != null) { + for (Characteristic n : resourceUpd.getResourceCharacteristic()) { + + if (resource.getResourceCharacteristicByName(n.getName()) != null) { + + Characteristic origChar = resource.getResourceCharacteristicByName(n.getName()); + if ((origChar != null) && (origChar.getValue() != null) && (origChar.getValue().getValue() != null)) { + if (!origChar.getValue().getValue().equals(n.getValue().getValue())) { + resourceCharacteristicChanged = true; + charsChanged = charsChanged + n.getName() + ","; + } + } + + resource.getResourceCharacteristicByName(n.getName()) + .setValue(new Any(n.getValue().getValue(), n.getValue().getAlias())); + } else { + resource.addResourceCharacteristicItem(n); + resourceCharacteristicChanged = true; + charsChanged = charsChanged + n.getName() + ","; + } + } + } + + if (resourceCharacteristicChanged) { + Note n = new Note(); + n.setText("Resource characteristics changed : " + charsChanged); + n.setAuthor( "RAM702-API" ); + n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); + resource.addNoteItem( n ); + + } + + if (resourceStateChanged) { + Note n = new Note(); + n.setText("Resource resourceStateChanged changed to " + resource.getResourceStatus().toString() ); + n.setAuthor( "RAM702-API" ); + n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); + resource.addNoteItem( n ); + + } + + if (resourceUpd.getActivationFeature() != null) { + for (Feature n : resourceUpd.getActivationFeature()) { + if (n.getId() != null) { + // we need to update this ? + } else { + resource.getActivationFeature().add(n); + } + + } + } + + resource = this.resourceRepo.save(resource); + + if (resourceCharacteristicChanged) { + raiseResourceAttributeValueChangeEventNotification(resource); + } else if (resourceStateChanged) { + raiseResourceStateChangeEventNotification(resource); + } + return resource; + } + + /** + * Retrieves a resource by UUID and returns it as a JSON string. + * + * @param id the UUID of the resource + * @return the resource as a JSON string + * @throws JsonProcessingException if JSON processing fails + * @throws ResourceNotFoundException if Resource not found + */ + public String getResourceEagerAsString(String id) throws JsonProcessingException, ResourceNotFoundException { + Resource s = this.getResourceEager(id); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString(s); + + return res; + } + + + /** + * Retrieves a resource by UUID with all associations eagerly loaded. + * + * @param id the UUID of the resource + * @return the resource with all associations initialized + * @throws ResourceNotFoundException if Resource not found + */ + public Resource getResourceEager(String id) throws ResourceNotFoundException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + Resource s = null; + try { + s = (Resource) session.get(Resource.class, id); + if (s == null) { + return this.findByUuid(id); + } + + Hibernate.initialize(s.getRelatedParty()); + Hibernate.initialize(s.getNote()); + Hibernate.initialize(s.getResourceCharacteristic()); + Hibernate.initialize(s.getResourceSpecification()); + Hibernate.initialize(s.getResourceRelationship()); + Hibernate.initialize(s.getAttachment()); + Hibernate.initialize(s.getActivationFeature()); + + tx.commit(); + } finally { + session.close(); + } + + return s; + } + + + /** + * Raises a resource create notification event. + * + * @param so the resource that was created + */ + @Transactional + private void raiseResourceCreateNotification(Resource so) { + ResourceCreateNotification n = new ResourceCreateNotification(); + ResourceCreateEvent event = new ResourceCreateEvent(); + event.getEvent().setResource(so); + n.setEvent(event); + resourceApiRouteBuilder.publishEvent(n, so.getId()); + + } + + + /** + * Raises a resource attribute value change notification event. + * + * @param so the resource that has changed + */ + @Transactional + private void raiseResourceAttributeValueChangeEventNotification(Resource so) { + ResourceAttributeValueChangeNotification n = new ResourceAttributeValueChangeNotification(); + ResourceAttributeValueChangeEvent event = new ResourceAttributeValueChangeEvent(); + event.getEvent().setResource(so); + n.setEvent(event); + resourceApiRouteBuilder.publishEvent(n, so.getId()); + + } + + + /** + * Raises a resource state change notification event. + * + * @param so the resource whose state has changed + */ + @Transactional + private void raiseResourceStateChangeEventNotification(Resource so) { + ResourceStateChangeNotification n = new ResourceStateChangeNotification(); + ResourceStateChangeEvent event = new ResourceStateChangeEvent(); + event.getEvent().setResource(so); + n.setEvent(event); + resourceApiRouteBuilder.publishEvent(n, so.getId()); + + } + + + /** + * Finds all active resources that need to be terminated. + * + * @return a list of resource UUIDs to terminate + */ + @Transactional + public List findAllActiveResourcesToTerminate() { + + List result = new ArrayList<>(); + List resourcs = this.resourceRepo.findActiveToTerminate(); + for (Resource r : resourcs) { + result.add(r.getId()); + } + + return result; + } + + + /** + * Deletes a resource by its UUID. + * + * @param id the UUID of the resource to delete + * @return null + * @throws ApiException + */ + public Void deleteByUuid(String id) throws ApiException { + Optional optionalCat = this.resourceRepo.findByUuid(id); + + if (optionalCat.isPresent()) { + Resource s = optionalCat.get(); + this.resourceRepo.delete(s); + + logger.info("Deleted resource with UUID = " + id); + } else { + throw new ApiException(404, "Resource not found with UUID: " + id); + } + + return null; + } + + + /** + * Adds a new resource or updates an existing one based on name, category, and version. + * + * @param aName the name of the resource + * @param aCategory the category of the resource + * @param aVersion the version of the resource + * @param resourceCreate the resource data to create or update + * @return the added or updated resource + */ + @Transactional + public Resource addOrUpdateResourceByNameCategoryVersion(String aName, String aCategory, + String aVersion, ResourceCreate aResourceCreate) throws ApiException { + + List resources = + this.resourceRepo.findByNameAndCategoryAndResourceVersion(aName, aCategory, aVersion); + Resource result = null; + + if (resources.size() > 0) { + // perform update to the first one + String resID = resources.get(0).getUuid(); + result = this.updateResource(resID, aResourceCreate, false); + + } else { + result = this.addResource(aResourceCreate); + } + + ObjectMapper mapper = new ObjectMapper(); + try { + String originaServiceAsJson = mapper.writeValueAsString(result); + logger.debug(originaServiceAsJson); + } catch (JsonProcessingException e) { + logger.error("cannot umarshall service: " + result.getName()); + e.printStackTrace(); + } + + return result; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java b/src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java new file mode 100644 index 0000000..9573c27 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java @@ -0,0 +1,361 @@ +package org.etsi.osl.tmf.ram702.utils; + +public class JSONResponseUtils { + public static final String RESOURCE_JSON_RESPONSE = "{\\r\\n" + // + " \\\"note\\\" : [ {\\r\\n" + // + " \\\"date\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"author\\\" : \\\"author\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"text\\\" : \\\"text\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"date\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"author\\\" : \\\"author\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"text\\\" : \\\"text\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"endOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"resourceVersion\\\" : \\\"resourceVersion\\\",\\r\\n" + // + " \\\"activationFeature\\\" : [ {\\r\\n" + // + " \\\"isBundle\\\" : true,\\r\\n" + // + " \\\"isEnabled\\\" : true,\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"featureCharacteristic\\\" : [ {\\r\\n" + // + " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"value\\\" : { }\\r\\n" + // + " }, {\\r\\n" + // + " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"value\\\" : { }\\r\\n" + // + " } ],\\r\\n" + // + " \\\"constraint\\\" : [ {\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"version\\\" : \\\"version\\\"\\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\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"version\\\" : \\\"version\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"featureRelationship\\\" : [ {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"validFor\\\" : {\\r\\n" + // + " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // + " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"validFor\\\" : {\\r\\n" + // + " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // + " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\"\\r\\n" + // + " } ]\\r\\n" + // + " }, {\\r\\n" + // + " \\\"isBundle\\\" : true,\\r\\n" + // + " \\\"isEnabled\\\" : true,\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"featureCharacteristic\\\" : [ {\\r\\n" + // + " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"value\\\" : { }\\r\\n" + // + " }, {\\r\\n" + // + " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"value\\\" : { }\\r\\n" + // + " } ],\\r\\n" + // + " \\\"constraint\\\" : [ {\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"version\\\" : \\\"version\\\"\\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\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"version\\\" : \\\"version\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"featureRelationship\\\" : [ {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"validFor\\\" : {\\r\\n" + // + " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // + " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // + " \\\"validFor\\\" : {\\r\\n" + // + " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // + " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\"\\r\\n" + // + " } ]\\r\\n" + // + " } ],\\r\\n" + // + " \\\"description\\\" : \\\"description\\\",\\r\\n" + // + " \\\"resourceCharacteristic\\\" : [ null, null ],\\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\\\" : \\\"http://example.com/aeiou\\\",\\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\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"attachment\\\" : [ {\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"attachmentType\\\" : \\\"video\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"description\\\" : \\\"Photograph of the Product\\\",\\r\\n" + // + " \\\"mimeType\\\" : \\\"mimeType\\\",\\r\\n" + // + " \\\"content\\\" : \\\"content\\\",\\r\\n" + // + " \\\"url\\\" : \\\"http://host/Content/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // + " \\\"size\\\" : {\\r\\n" + // + " \\\"amount\\\" : 0.8008282,\\r\\n" + // + " \\\"units\\\" : \\\"units\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://host/Attachment/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"attachmentType\\\" : \\\"video\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"description\\\" : \\\"Photograph of the Product\\\",\\r\\n" + // + " \\\"mimeType\\\" : \\\"mimeType\\\",\\r\\n" + // + " \\\"content\\\" : \\\"content\\\",\\r\\n" + // + " \\\"url\\\" : \\\"http://host/Content/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // + " \\\"size\\\" : {\\r\\n" + // + " \\\"amount\\\" : 0.8008282,\\r\\n" + // + " \\\"units\\\" : \\\"units\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://host/Attachment/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"administrativeState\\\" : \\\"locked\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"resourceRelationship\\\" : [ {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"bundled\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"resource\\\" : {\\r\\n" + // + " \\\"note\\\" : [ null, null ],\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"endOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"resourceVersion\\\" : \\\"resourceVersion\\\",\\r\\n" + // + " \\\"activationFeature\\\" : [ null, null ],\\r\\n" + // + " \\\"resourceSpecification\\\" : {\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"version\\\" : \\\"version\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"description\\\" : \\\"description\\\",\\r\\n" + // + " \\\"resourceCharacteristic\\\" : [ null, null ],\\r\\n" + // + " \\\"relatedParty\\\" : [ null, null ],\\r\\n" + // + " \\\"resourceStatus\\\" : \\\"standby\\\",\\r\\n" + // + " \\\"usageState\\\" : \\\"idle\\\",\\r\\n" + // + " \\\"attachment\\\" : [ null, null ],\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"resourceRelationship\\\" : [ null, null ],\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"href\\\",\\r\\n" + // + " \\\"startOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"category\\\" : \\\"category\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " }, {\\r\\n" + // + " \\\"relationshipType\\\" : \\\"bundled\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"resource\\\" : {\\r\\n" + // + " \\\"note\\\" : [ null, null ],\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"endOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"resourceVersion\\\" : \\\"resourceVersion\\\",\\r\\n" + // + " \\\"activationFeature\\\" : [ null, null ],\\r\\n" + // + " \\\"resourceSpecification\\\" : {\\r\\n" + // + " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"version\\\" : \\\"version\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"description\\\" : \\\"description\\\",\\r\\n" + // + " \\\"resourceCharacteristic\\\" : [ null, null ],\\r\\n" + // + " \\\"relatedParty\\\" : [ null, null ],\\r\\n" + // + " \\\"resourceStatus\\\" : \\\"standby\\\",\\r\\n" + // + " \\\"usageState\\\" : \\\"idle\\\",\\r\\n" + // + " \\\"attachment\\\" : [ null, null ],\\r\\n" + // + " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // + " \\\"name\\\" : \\\"name\\\",\\r\\n" + // + " \\\"resourceRelationship\\\" : [ null, null ],\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"href\\\",\\r\\n" + // + " \\\"startOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"category\\\" : \\\"category\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " },\\r\\n" + // + " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + " } ],\\r\\n" + // + " \\\"id\\\" : \\\"id\\\",\\r\\n" + // + " \\\"href\\\" : \\\"href\\\",\\r\\n" + // + " \\\"startOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // + " \\\"operationalState\\\" : \\\"enable\\\",\\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" + // + " \\\"category\\\" : \\\"category\\\",\\r\\n" + // + " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // + "}"; + + public static final String RESOURCE_LIST_JSON_RESPONSE = "[" + RESOURCE_JSON_RESPONSE + "]"; +} 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 fc6252f..3d47f0f 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 @@ -73,14 +73,14 @@ public class ResourceApiRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { - from( CATALOG_ADD_RESOURCE ) - .log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " 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_ADD_RESOURCE ) + //.log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " 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_GET_RESOURCE_BY_ID ) .log(LoggingLevel.INFO, log, CATALOG_GET_RESOURCE_BY_ID + " message received!") @@ -88,13 +88,13 @@ public class ResourceApiRouteBuilder extends RouteBuilder { .bean( resourceRepoService, "getResourceEagerAsString") .convertBodyTo( String.class ); - from( CATALOG_UPD_RESOURCE ) - .log(LoggingLevel.INFO, 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} )") - .marshal().json( JsonLibrary.Jackson) - .convertBodyTo( String.class ); + //from( CATALOG_UPD_RESOURCE ) + //.log(LoggingLevel.INFO, 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} )") + //.marshal().json( JsonLibrary.Jackson) + //.convertBodyTo( String.class ); from( CATALOG_RESOURCES_OF_PARTNERS ) .log(LoggingLevel.INFO, log, CATALOG_RESOURCES_OF_PARTNERS + " message received!") @@ -103,13 +103,13 @@ public class ResourceApiRouteBuilder extends RouteBuilder { .marshal().json( JsonLibrary.Jackson) .convertBodyTo( String.class ); - from( CATALOG_UPDADD_RESOURCE ) - .log(LoggingLevel.INFO, 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})") - .marshal().json( JsonLibrary.Jackson) - .convertBodyTo( String.class ); + //from( CATALOG_UPDADD_RESOURCE ) + //.log(LoggingLevel.INFO, 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})") + //.marshal().json( JsonLibrary.Jackson) + //.convertBodyTo( String.class ); } diff --git a/src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java b/src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java new file mode 100644 index 0000000..5703507 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java @@ -0,0 +1,418 @@ +package org.etsi.osl.services.reposervices.ram702; + +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.ram702.api.ApiException; +import org.etsi.osl.tmf.ram702.api.ResourceNotFoundException; +import org.etsi.osl.tmf.ram702.repo.ResourceActivationRepository; +import org.etsi.osl.tmf.ram702.reposervices.ResourceActivationRepoService; +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.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +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 ResourceActivationRepoService}. + * + * This class uses Mockito and Spring's testing framework to mock dependencies + * and verify the behavior of the ResourceActivationRepoService. + */ +@RunWith(SpringRunner.class) +@ActiveProfiles("testing") +@SpringBootTest(classes = OpenAPISpringBoot.class) +public class ResourceActivationRepoServiceTest { + /** + * The service being tested, with a spy to allow partial mocking of certain methods. + */ + @SpyBean + @Autowired + private ResourceActivationRepoService resourceActivationRepoService; + + /** + * Mock for the {@link ResourceActivationRepository} to simulate repository operations. + */ + @MockBean + private ResourceActivationRepository resourceActivationRepo; + + 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() throws ResourceNotFoundException { + when(resourceActivationRepo.findByUuid(anyString())).thenReturn(Optional.of(resource)); + when(resourceActivationRepo.save(any(Resource.class))).thenReturn(resource); + doReturn(resource).when(resourceActivationRepoService).getResourceEager(anyString()); + } + + /** + * Test for {@link ResourceActivationRepoService#findByUuid(String)} when a resource is found. + * + * @throws ResourceNotFoundException if the resource is not found (not expected). + */ + @Test + public void testFindByUuidWhenResourceIsFound() throws ResourceNotFoundException { + // When + Resource result = resourceActivationRepoService.findByUuid(anyString()); + + // Then + assertNotNull(result); + verify(resourceActivationRepo, times(1)).findByUuid(anyString()); + } + + /** + * Test for {@link ResourceActivationRepoService#findByUuid(String)} when no resource is found. + * This ensures that a {@link ResourceNotFoundException} is thrown when the resource does not exist. + * + * @throws ResourceNotFoundException expected exception if the resource is not found. + */ + @Test + public void testFindByUuidWhenResourceIsNotFound() throws ResourceNotFoundException { + // Given + when(resourceActivationRepo.findByUuid(anyString())).thenReturn(Optional.empty()); + + // When + ResourceNotFoundException exception = assertThrows(ResourceNotFoundException.class, () -> { + resourceActivationRepoService.findByUuid("123"); + }); + + // Then + assertEquals("Resource not found with UUID: 123", exception.getMessage()); + } + + /** + * Test for {@link ResourceActivationRepoService#findAll()} to verify it retrieves all resources. + */ + @Test + public void testFindAllResources() { + // Given + List 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(resourceActivationRepo.findAll()).thenReturn(resources); + + // When + List result = resourceActivationRepoService.findAll(); + + // Then + assertNotNull(result); + assertEquals(2, result.size()); + assertEquals("resource1", result.get(0).getName()); + assertEquals("resource2", result.get(1).getName()); + verify(resourceActivationRepo, times(1)).findAll(); + } + + /** + * Test for {@link ResourceActivationRepoService#addResource(ResourceCreate)} to verify resource creation. + */ + @Test + public void testAddResource() { + // When + Resource result = resourceActivationRepoService.addResource(resourceCreate); + + // Then + assertNotNull(result); + assertEquals("test_resource", result.getName()); + verify(resourceActivationRepo, times(1)).save(any(Resource.class)); + } + + /** + * Test for {@link ResourceActivationRepoService#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() throws ResourceNotFoundException{ + 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 = resourceActivationRepoService.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(resourceActivationRepo, times(1)).save(any(Resource.class)); + } + + /** + * Test for {@link ResourceActivationRepoService#updateResource(String, ResourceUpdate, boolean)} + * to verify that a {@link ResourceNotFoundException} is thrown when the resource does not exist. + * @throws ResourceNotFoundException + */ + @Test + public void testUpdateResourceWhenResourceIsNotFound() throws ResourceNotFoundException { + // Given + doReturn(null).when(resourceActivationRepoService).getResourceEager(anyString()); + ResourceUpdate update = new ResourceUpdate(); + + // When + ResourceNotFoundException exception = assertThrows(ResourceNotFoundException.class, () -> { + resourceActivationRepoService.updateResource("123", update, false); + }); + + // Then + assertEquals("Resource not found with UUID: 123", exception.getMessage()); + verify(resourceActivationRepo, never()).save(any(Resource.class)); + } + + /** + * Test for {@link ResourceActivationRepoService#deleteByUuid(String)} to verify successful resource deletion. + * + * @throws ApiException if there is an error during the deletion process (not expected). + */ + @Test + public void testDeleteByUuidWhenResourceIsFound() throws ApiException { + // When + resourceActivationRepoService.deleteByUuid("123"); + + // Then + verify(resourceActivationRepo, times(1)).delete(resource); + } + + /** + * Test for {@link ResourceActivationRepoService#deleteByUuid(String)} to verify that an {@link ApiException} + * is thrown when the resource to delete is not found. + */ + @Test + public void testDeleteByUuidWhenResourceIsNotFound() { + // Given + when(resourceActivationRepo.findByUuid("123")).thenReturn(Optional.empty()); + + // When + ApiException exception = assertThrows(ApiException.class, () -> { + resourceActivationRepoService.deleteByUuid("123"); + }); + + // Then + assertEquals("Resource not found with UUID: 123", exception.getMessage()); + verify(resourceActivationRepo, never()).delete(any(Resource.class)); + } + + /** + * Test for {@link ResourceActivationRepoService#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() throws ApiException { + // Given + ResourceUpdate update = new ResourceUpdate(); + update.setName("updated_name"); + + String name = "test_resource"; + String category = "Category 1"; + String version = "1.0"; + + List existingResources = Collections.singletonList(resource); + + // Mock the repository to return the existing resource + when(resourceActivationRepo.findByNameAndCategoryAndResourceVersion(anyString(), anyString(), anyString())) + .thenReturn(existingResources); + + // Mock the updateResource method to return the updated resource + when(resourceActivationRepoService.updateResource("123", update, false)) + .thenReturn(resource); + + // When + Resource result = resourceActivationRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); + + // Then + assertNotNull(result); + assertEquals("test_resource", result.getName()); + verify(resourceActivationRepoService, times(1)).updateResource("123", update, false); + } + + /** + * Test for {@link ResourceActivationRepoService#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() throws ApiException { + // Given + String name = "test_resource"; + String category = "Category 1"; + String version = "1.0"; + + // Mock an empty list of existing resources + List noResources = new ArrayList<>(); + + // Mock the repository to return no existing resources + when(resourceActivationRepo.findByNameAndCategoryAndResourceVersion(anyString(), anyString(), anyString())) + .thenReturn(noResources); + + // Mock the addResource method to return the newly created resource + when(resourceActivationRepoService.addResource(resourceCreate)).thenReturn(resource); + + // When + Resource result = resourceActivationRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); + + // Then + assertNotNull(result); + assertEquals("test_resource", result.getName()); + verify(resourceActivationRepoService, times(1)).addResource(any(ResourceCreate.class)); + verify(resourceActivationRepoService, never()).updateResource(result.getId(), resourceCreate, false); + } + + /** + * Test for {@link ResourceActivationRepoService#addOrUpdateResourceByNameCategoryVersion(String, String, String, ResourceCreate)} + * to handle an {@link ApiException} being thrown during the process. + * + * @throws ApiException expected exception during the process. + */ + @Test + public void testAddOrUpdateResourceByNameCategoryVersionThrowsApiException() throws ApiException { + // Given + String name = "Faulty Resource"; + String category = "Faulty Category"; + String version = "1.0"; + + // Mock an existing resource + List existingResources = Collections.singletonList(resource); + + // Mock the repository to return the existing resource + when(resourceActivationRepo.findByNameAndCategoryAndResourceVersion(name, category, version)) + .thenReturn(existingResources); + + // Mock the updateResource method to throw an ApiException + doThrow(new ResourceNotFoundException("Error updating resource")) + .when(resourceActivationRepoService).updateResource(resource.getId(), resourceCreate, false); + + // When and Then + ApiException exception = assertThrows(ApiException.class, () -> { + resourceActivationRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); + }); + + assertEquals("Error updating resource", exception.getMessage()); + verify(resourceActivationRepoService, times(1)).updateResource(resource.getId(), resourceCreate, false); + verify(resourceActivationRepoService, never()).addResource(resourceCreate); // Add should not be called + } + + /** + * Test for {@link ResourceActivationRepoService#raiseResourceAttributeValueChangeEventNotification(Resource)} + * to ensure a resource attribute value change notification is published. + */ + @Test + public void testFindAllActiveResourcesToTerminate() { + // Given + List resources = new ArrayList<>(); + Resource resource1 = mock(Resource.class); + when(resource1.getId()).thenReturn("uuid1"); + resources.add(resource1); + + when(resourceActivationRepo.findActiveToTerminate()).thenReturn(resources); + + // When + List result = resourceActivationRepoService.findAllActiveResourcesToTerminate(); + + // Then + assertNotNull(result); + assertEquals(1, result.size()); + assertEquals("uuid1", result.get(0)); + verify(resourceActivationRepo, times(1)).findActiveToTerminate(); + } +} diff --git a/src/test/resources/reposervices/ram702/resource.json b/src/test/resources/reposervices/ram702/resource.json new file mode 100644 index 0000000..609d70d --- /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 0000000..59d75d8 --- /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 -- GitLab From d02c9d8e853997141c47622117c777d15bb06519 Mon Sep 17 00:00:00 2001 From: Eduardo Santos Date: Thu, 7 Nov 2024 11:35:03 +0000 Subject: [PATCH 17/59] Removed changes on TMF639 to make TMF702's MR atomic --- .../ri639/api/ResourceApiRouteBuilder.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) 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 3d47f0f..fc6252f 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 @@ -73,14 +73,14 @@ public class ResourceApiRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { - //from( CATALOG_ADD_RESOURCE ) - //.log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " 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_ADD_RESOURCE ) + .log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " 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_GET_RESOURCE_BY_ID ) .log(LoggingLevel.INFO, log, CATALOG_GET_RESOURCE_BY_ID + " message received!") @@ -88,13 +88,13 @@ public class ResourceApiRouteBuilder extends RouteBuilder { .bean( resourceRepoService, "getResourceEagerAsString") .convertBodyTo( String.class ); - //from( CATALOG_UPD_RESOURCE ) - //.log(LoggingLevel.INFO, 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} )") - //.marshal().json( JsonLibrary.Jackson) - //.convertBodyTo( String.class ); + from( CATALOG_UPD_RESOURCE ) + .log(LoggingLevel.INFO, 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} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); from( CATALOG_RESOURCES_OF_PARTNERS ) .log(LoggingLevel.INFO, log, CATALOG_RESOURCES_OF_PARTNERS + " message received!") @@ -103,13 +103,13 @@ public class ResourceApiRouteBuilder extends RouteBuilder { .marshal().json( JsonLibrary.Jackson) .convertBodyTo( String.class ); - //from( CATALOG_UPDADD_RESOURCE ) - //.log(LoggingLevel.INFO, 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})") - //.marshal().json( JsonLibrary.Jackson) - //.convertBodyTo( String.class ); + from( CATALOG_UPDADD_RESOURCE ) + .log(LoggingLevel.INFO, 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})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); } -- GitLab From 4147a21b07154cb37d095b86c802aac70aeb7f2d Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 12:11:57 +0200 Subject: [PATCH 18/59] ignore test --- .../api/AlarmManagementIntegrationTest.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 df10383..bb373c2 100644 --- a/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java @@ -249,22 +249,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()); -- GitLab From 6bbb399d47f88d35a081b0dfd50333f3dc2dc60a Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 12:49:37 +0200 Subject: [PATCH 19/59] adding annotations --- .../scm633/ServiceSpecificationRepoServiceTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 c5e3082..8033d6c 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 -- GitLab From 53583e88431174718f4566f29186aec8c5717b42 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 12:58:01 +0200 Subject: [PATCH 20/59] fix for #49 --- .../api/AlarmManagementIntegrationTest.java | 2 ++ ...ServiceSpecificationApiControllerTest.java | 20 +++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) 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 bb373c2..eb570b4 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()); 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 dea6f82..9c727ec 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 @@ -82,7 +82,7 @@ public class ServiceSpecificationApiControllerTest { } @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testDeleteServiceSpecification() throws Exception { assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); @@ -102,7 +102,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testListServiceSpecification() throws Exception { String response = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification") @@ -127,7 +127,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testPatchServiceSpecification() throws Exception { String response = createServiceSpecification(); @@ -164,7 +164,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testRetrieveServiceSpecification() throws Exception { String response = createServiceSpecification(); @@ -186,7 +186,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testGetAttachment() throws Exception { // Create a Service Specification @@ -233,7 +233,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testGetAttachmentWithFilename() throws Exception { // Create a Service Specification @@ -259,7 +259,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testRetrieveServiceSpecificationDescriptor() throws Exception { // Test a non-existing spec @@ -271,7 +271,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username = "osadmin", roles = { "ADMIN","USER" }) - @Test + //@Test public void testSpecFromTestSpec() throws Exception { // Creeate a Test Spec @@ -316,7 +316,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - @Test + //@Test public void testGetImageSpecificationRelationshipGraph() throws Exception { // Create a Service Specification @@ -334,7 +334,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN"}) - @Test + //@Test public void testSpecFromResourceSpec() throws Exception { File rspec = new File( "src/test/resources/testResourceSpec.json" ); -- GitLab From 4ec8520ca8fd4bc185fdda8852190d79c6f1c17d Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 13:03:31 +0200 Subject: [PATCH 21/59] fix for #49 --- ...ServiceSpecificationApiControllerTest.java | 20 ++++++++-------- .../ServiceSpecificationRepoServiceTest.java | 24 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) 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 9c727ec..dea6f82 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 @@ -82,7 +82,7 @@ public class ServiceSpecificationApiControllerTest { } @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testDeleteServiceSpecification() throws Exception { assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); @@ -102,7 +102,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testListServiceSpecification() throws Exception { String response = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification") @@ -127,7 +127,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testPatchServiceSpecification() throws Exception { String response = createServiceSpecification(); @@ -164,7 +164,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testRetrieveServiceSpecification() throws Exception { String response = createServiceSpecification(); @@ -186,7 +186,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testGetAttachment() throws Exception { // Create a Service Specification @@ -233,7 +233,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testGetAttachmentWithFilename() throws Exception { // Create a Service Specification @@ -259,7 +259,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testRetrieveServiceSpecificationDescriptor() throws Exception { // Test a non-existing spec @@ -271,7 +271,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username = "osadmin", roles = { "ADMIN","USER" }) - //@Test + @Test public void testSpecFromTestSpec() throws Exception { // Creeate a Test Spec @@ -316,7 +316,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) - //@Test + @Test public void testGetImageSpecificationRelationshipGraph() throws Exception { // Create a Service Specification @@ -334,7 +334,7 @@ public class ServiceSpecificationApiControllerTest { @WithMockUser(username="osadmin", roles = {"ADMIN"}) - //@Test + @Test public void testSpecFromResourceSpec() throws Exception { File rspec = new File( "src/test/resources/testResourceSpec.json" ); 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 8033d6c..f0933f5 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 @@ -48,12 +48,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.validation.Valid; -@RunWith(SpringRunner.class) -@ActiveProfiles("testing") -@Transactional -@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) -@AutoConfigureMockMvc -@AutoConfigureTestDatabase +//@RunWith(SpringRunner.class) +//@ActiveProfiles("testing") +//@Transactional +//@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +//@AutoConfigureMockMvc +//@AutoConfigureTestDatabase public class ServiceSpecificationRepoServiceTest { @Autowired @@ -69,7 +69,7 @@ public class ServiceSpecificationRepoServiceTest { private static ResourceSpecification resourceNSD; - @BeforeClass + //@BeforeClass public static void setupBeforeClass() { // Load NSD from JSON file to NetworkServiceDescriptor.class try { @@ -94,7 +94,7 @@ public class ServiceSpecificationRepoServiceTest { resourceNSD.setDescription(nsd.getShortDescription()); } - @Before + //@Before public void setupBefore() { when(serviceSpecificationApiRouteBuilderNSD.retrieveNSD(anyString())).thenReturn(nsd); when(resourceSpecRepoService.addResourceSpec(any())).thenReturn(resourceNSD); @@ -107,7 +107,7 @@ public class ServiceSpecificationRepoServiceTest { * This test verifies that the method retrieveNSD correctly returns a non-null NetworkServiceDescriptor * and that the specFromNSDID method does not return null in such a case. */ - @Test + //@Test public void testSpecFromNSDIDReturnsNonNullWhenRetrieveNSDReturnsNonNull() { // Setup String id = "testId"; @@ -127,7 +127,7 @@ public class ServiceSpecificationRepoServiceTest { * * This test verifies that the method retrieveNSD correctly returns null when it is expected to. */ - @Test + //@Test public void testRetrieveNSDReturnsNull() { // When retrieveNSD return null String id = "SomeId"; @@ -148,7 +148,7 @@ public class ServiceSpecificationRepoServiceTest { * has the correct name, version, and description. It also checks that the correct number * of ServiceSpecification objects are created. */ - @Test + //@Test public void testServiceSpecificationBaseProperties() { String testId = "validId"; @@ -177,7 +177,7 @@ public class ServiceSpecificationRepoServiceTest { * that this object has the expected characteristics, including the correct name, value, and alias * for each characteristic. */ - @Test + //@Test public void testServiceSpecificationCharacteristics() { String testId = "validId"; -- GitLab From e84344f369c8d4f6606262d6475f9618d4e50058 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 13:16:30 +0200 Subject: [PATCH 22/59] fix for #49 --- .../etsi/osl/services/api/ProductCatalogIntegrationTest.java | 2 +- .../etsi/osl/services/api/sim638/ServiceRepoServiceTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 fc2b66e..da1f9c8 100644 --- a/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java @@ -84,7 +84,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/sim638/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java index d011129..4309b09 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 @@ -58,7 +58,7 @@ 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( -- GitLab From 5f7f78080dd82987668ea8c43a0442a0c2dc6b59 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 13:18:52 +0200 Subject: [PATCH 23/59] fix for #49 --- .../org/etsi/osl/services/api/ProductCatalogIntegrationTest.java | 1 + 1 file changed, 1 insertion(+) 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 da1f9c8..80b58e3 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; -- GitLab From 8e204be8bff5bebed875f759d1d212b4c70c1840 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 14:09:14 +0200 Subject: [PATCH 24/59] fix for #49 --- pom.xml | 9 ++++----- .../services/api/scm633/HubApiControllerTest.java | 2 ++ .../scm633/ServiceCandidateApiControllerTest.java | 2 ++ .../api/scm633/ServiceCatalogApiControllerTest.java | 2 ++ .../api/scm633/ServiceCategoryApiControllerTest.java | 2 ++ .../api/so641/ServiceOrderApiControllerTest.java | 3 ++- .../api/so641/ServiceOrderRepoServiceTest.java | 3 ++- ...iceTest.java => ServiceNSLCMRepoServiceTest.java} | 12 ++++++++---- 8 files changed, 24 insertions(+), 11 deletions(-) rename src/test/java/org/etsi/osl/services/service/{ServiceRepoServiceTest.java => ServiceNSLCMRepoServiceTest.java} (98%) diff --git a/pom.xml b/pom.xml index 51dad97..17b9880 100644 --- a/pom.xml +++ b/pom.xml @@ -437,6 +437,10 @@ org.apache.maven.plugins maven-surefire-plugin 3.2.5 + + + none + org.jacoco @@ -458,11 +462,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 3.2.5 - org.jacoco jacoco-maven-plugin 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 048ad19..db51361 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 c8ed3f4..be25caf 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 92b48d5..65080e8 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 865ca45..4163c54 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/so641/ServiceOrderApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderApiControllerTest.java index 305d454..ac1dad1 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 2cc5b0e..dc3a7c1 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/service/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/service/ServiceNSLCMRepoServiceTest.java similarity index 98% 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 fbd4718..29ea3bd 100644 --- a/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/service/ServiceNSLCMRepoServiceTest.java @@ -37,21 +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; -- GitLab From 128f54158edf4ea602e8e5c994a2684db4d1dcdc Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 14:26:43 +0200 Subject: [PATCH 25/59] fix for #49 --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 17b9880..85354aa 100644 --- a/pom.xml +++ b/pom.xml @@ -440,6 +440,8 @@ none + alphabetical + 1 -- GitLab From 12b111ad172e897664808299da4fc60abf87a508 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 20 Nov 2024 15:23:24 +0200 Subject: [PATCH 26/59] fix for #49 --- .../ServiceSpecificationRepoServiceTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) 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 f0933f5..8033d6c 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 @@ -48,12 +48,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.validation.Valid; -//@RunWith(SpringRunner.class) -//@ActiveProfiles("testing") -//@Transactional -//@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) -//@AutoConfigureMockMvc -//@AutoConfigureTestDatabase +@RunWith(SpringRunner.class) +@ActiveProfiles("testing") +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@AutoConfigureTestDatabase public class ServiceSpecificationRepoServiceTest { @Autowired @@ -69,7 +69,7 @@ public class ServiceSpecificationRepoServiceTest { private static ResourceSpecification resourceNSD; - //@BeforeClass + @BeforeClass public static void setupBeforeClass() { // Load NSD from JSON file to NetworkServiceDescriptor.class try { @@ -94,7 +94,7 @@ public class ServiceSpecificationRepoServiceTest { resourceNSD.setDescription(nsd.getShortDescription()); } - //@Before + @Before public void setupBefore() { when(serviceSpecificationApiRouteBuilderNSD.retrieveNSD(anyString())).thenReturn(nsd); when(resourceSpecRepoService.addResourceSpec(any())).thenReturn(resourceNSD); @@ -107,7 +107,7 @@ public class ServiceSpecificationRepoServiceTest { * This test verifies that the method retrieveNSD correctly returns a non-null NetworkServiceDescriptor * and that the specFromNSDID method does not return null in such a case. */ - //@Test + @Test public void testSpecFromNSDIDReturnsNonNullWhenRetrieveNSDReturnsNonNull() { // Setup String id = "testId"; @@ -127,7 +127,7 @@ public class ServiceSpecificationRepoServiceTest { * * This test verifies that the method retrieveNSD correctly returns null when it is expected to. */ - //@Test + @Test public void testRetrieveNSDReturnsNull() { // When retrieveNSD return null String id = "SomeId"; @@ -148,7 +148,7 @@ public class ServiceSpecificationRepoServiceTest { * has the correct name, version, and description. It also checks that the correct number * of ServiceSpecification objects are created. */ - //@Test + @Test public void testServiceSpecificationBaseProperties() { String testId = "validId"; @@ -177,7 +177,7 @@ public class ServiceSpecificationRepoServiceTest { * that this object has the expected characteristics, including the correct name, value, and alias * for each characteristic. */ - //@Test + @Test public void testServiceSpecificationCharacteristics() { String testId = "validId"; -- GitLab From 6a3c14b8aea9fdb54f8567a0ce0f275b9f9d5d43 Mon Sep 17 00:00:00 2001 From: Nikolaos Kyriakoulis Date: Mon, 25 Nov 2024 16:14:25 +0000 Subject: [PATCH 27/59] Implemented pm628 API --- .factorypath | 4 +- .../SwaggerDocumentationConfig.java | 78 +- .../java/org/etsi/osl/tmf/pm628/README.md | 21 + .../org/etsi/osl/tmf/pm628/api/ApiUtil.java | 19 + .../tmf/pm628/api/DataAccessEndpointApi.java | 273 +++++++ .../api/DataAccessEndpointApiController.java | 75 ++ .../org/etsi/osl/tmf/pm628/api/HubApi.java | 134 ++++ .../osl/tmf/pm628/api/HubApiController.java | 28 + .../etsi/osl/tmf/pm628/api/ListenerApi.java | 389 ++++++++++ .../tmf/pm628/api/ListenerApiController.java | 28 + .../api/MeasurementCollectionJobApi.java | 692 ++++++++++++++++++ ...MeasurementCollectionJobApiController.java | 126 ++++ ...asurementCollectionJobApiRouteBuilder.java | 93 +++ ...entCollectionJobApiRouteBuilderEvents.java | 103 +++ ...ormanceIndicatorGroupSpecificationApi.java | 690 +++++++++++++++++ ...icatorGroupSpecificationApiController.java | 28 + .../PerformanceIndicatorSpecificationApi.java | 690 +++++++++++++++++ ...ceIndicatorSpecificationApiController.java | 123 ++++ .../pm628/api/PerformanceMeasurementApi.java | 273 +++++++ .../PerformanceMeasurementApiController.java | 28 + .../osl/tmf/pm628/api/TrackingRecordApi.java | 273 +++++++ .../api/TrackingRecordApiController.java | 28 + .../repo/DataAccessEndpointRepository.java | 13 + .../MeasurementCollectionJobRepository.java | 16 + ...manceIndicatorSpecificationRepository.java | 13 + .../DataAccessEndpointService.java | 71 ++ .../MeasurementCollectionJobService.java | 396 ++++++++++ ...formanceIndicatorSpecificationService.java | 68 ++ .../etsi/osl/tmf/util/RFC3339DateFormat.java | 38 + src/main/resources/application-testing.yml | 10 + src/main/resources/application.yml | 10 + ...urementCollectionJobApiControllerTest.java | 249 +++++++ .../MeasurementCollectionJobServiceTest.java | 195 +++++ .../testMeasurementCollectionJobFVO.json | 271 +++++++ 34 files changed, 5521 insertions(+), 25 deletions(-) create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/README.md create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/ApiUtil.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/HubApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/HubApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/ListenerApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilderEvents.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorGroupSpecificationApiController.java create mode 100755 src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApi.java create mode 100755 src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceIndicatorSpecificationApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/PerformanceMeasurementApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApi.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/api/TrackingRecordApiController.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/repo/DataAccessEndpointRepository.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/repo/MeasurementCollectionJobRepository.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/repo/PerformanceIndicatorSpecificationRepository.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/reposervices/DataAccessEndpointService.java create mode 100755 src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java create mode 100644 src/main/java/org/etsi/osl/tmf/pm628/reposervices/PerformanceIndicatorSpecificationService.java create mode 100644 src/main/java/org/etsi/osl/tmf/util/RFC3339DateFormat.java create mode 100644 src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobApiControllerTest.java create mode 100644 src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobServiceTest.java create mode 100644 src/test/resources/testMeasurementCollectionJobFVO.json diff --git a/.factorypath b/.factorypath index 64aa783..d2a2648 100644 --- a/.factorypath +++ b/.factorypath @@ -1,4 +1,4 @@ - - + + 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 239be29..d9433a3 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")); @@ -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")); @@ -183,7 +183,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 +217,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 +255,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 +291,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 +328,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 +366,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 +403,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 +442,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 +479,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 +516,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 +555,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 +594,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 +633,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 +671,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 +709,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 +744,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 +781,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 +826,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 +845,38 @@ 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(); + + } // @Bean 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 0000000..5cd22b6 --- /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 0000000..0ad52b6 --- /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 0000000..147ee55 --- /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 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> 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 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 0000000..13598a5 --- /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 getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity> 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>(dataAccessEndpointService.findAllDataAccessEndpoints(), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity 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(dataAccessEndpointService.findDataAccessEndpointByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(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 0000000..c9c67a5 --- /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 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 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 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 0000000..77be4ef --- /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 +@RequestMapping("/performance/v5") +public class HubApiController implements HubApi { + + private final NativeWebRequest request; + + @Autowired + public HubApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional 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 0000000..3ead3a9 --- /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 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 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 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 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 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 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 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 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 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 0000000..aab852d --- /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 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 0000000..e49e945 --- /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 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 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 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> 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 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 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 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 0000000..f23964e --- /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 getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity 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(measurementCollectionJobService.createMeasurementCollectionJob(measurementCollectionJobFVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity deleteMeasurementCollectionJob( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + try { + return new ResponseEntity(measurementCollectionJobService.deleteMeasurementCollectionJob(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity> 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 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>(measurementCollectionJobService.findAll(fields, allParams), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity 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(measurementCollectionJobService.updateMeasurementCollectionJob(id, measurementCollectionJobMVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity 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(measurementCollectionJobService.findMeasurementCollectionJobByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(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 0000000..0e5e1c7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java @@ -0,0 +1,93 @@ +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_GET_MEASUREMENT_COLLECTION_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_GET_MEASUREMENT_COLLECTION_JOB_BY_ID) + .log(LoggingLevel.INFO, log, PM_GET_MEASUREMENT_COLLECTION_JOB_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean(measurementCollectionJobService, "findMeasurementCollectionJobByUuid") + .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})") + .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})") + .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 toJsonObj(String content, Class 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 0000000..8bbb2fb --- /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 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 toJsonObj(String content, Class 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 0000000..e25a866 --- /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 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 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 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> 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 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 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 0000000..03a4e52 --- /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 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 0000000..f5c96ef --- /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 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 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 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> 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 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 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 0000000..d86b31f --- /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 getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity 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(performanceIndicatorSpecificationService.createPerformanceIndicatorSpecification(performanceIndicatorSpecificationFVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity deletePerformanceIndicatorSpecification( + @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + try { + return new ResponseEntity(performanceIndicatorSpecificationService.deletePerformanceIndicatorSpecification(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity> 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>(performanceIndicatorSpecificationService.findAllPerformanceIndicatorSpecifications(), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity 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(performanceIndicatorSpecificationService.updatePerformanceIndicatorSpecification(id, performanceIndicatorSpecificationMVO), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasRole('ROLE_USER')") + @Override + public ResponseEntity 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(performanceIndicatorSpecificationService.findPerformanceIndicatorSpecificationByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(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 0000000..cc3a71f --- /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 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> 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 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 0000000..d9e059e --- /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 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 0000000..516e974 --- /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 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> 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 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 0000000..0cddb31 --- /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 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 0000000..71ae6bc --- /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, PagingAndSortingRepository { + Optional 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 0000000..444e9d0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/repo/MeasurementCollectionJobRepository.java @@ -0,0 +1,16 @@ +package org.etsi.osl.tmf.pm628.repo; + +import org.etsi.osl.tmf.pm628.model.ExecutionStateType; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface MeasurementCollectionJobRepository extends CrudRepository, PagingAndSortingRepository { + Optional findByUuid(String uuid); + + Iterable 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 0000000..0764d9c --- /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, PagingAndSortingRepository { + Optional 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 0000000..4b7c002 --- /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 findAllDataAccessEndpoints(){ + log.debug("DataAccessEndpoint LIST"); + return (List) dataAccessEndpointRepository.findAll(); + } + + public DataAccessEndpoint findDataAccessEndpointByUuid(String uuid){ + log.debug("DataAccessEndpoint FIND BY UUID"); + Optional 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 0000000..9aecf9e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java @@ -0,0 +1,396 @@ +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.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.Transactional; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.util.*; + +@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 findAllMeasurementCollectionJobs(){ + log.debug("MeasurementCollectionJobService: LIST"); + return (List) measurementCollectionJobRepository.findAll(); + } + + public List findAllByExecutionState(ExecutionStateType executionState) { + log.debug("find by state:" + executionState ); + return (List) this.measurementCollectionJobRepository.findByExecutionState(executionState); + } + + @Transactional + public List findAll(@Valid String fields, Map allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List> 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 entry : allParams.entrySet()) { + query.setParameter(entry.getKey(), "%" + URLDecoder.decode(entry.getValue(), StandardCharsets.UTF_8.toString()) + "%"); + } + + List queryResult = query.list(); + Map> mcJobMap = new LinkedHashMap<>(); + Map> daeMap = new LinkedHashMap<>(); + Map> 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 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>()); + mcJobData.put("scheduleDefinition", new ArrayList>()); + + 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 daeData = daeMap.computeIfAbsent(daeUuid, k -> { + Map 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()); + newDaeData.put("resourceOrderItem", new ArrayList>()); + ((List>) mcJobMap.get(mcjUuid).get("dataAccessEndpoint")).add(newDaeData); + return newDaeData; + }); + + // Create uriQueryFilter map and add mappings + Map uriQueryFilter = (Map) daeData.get("uriQueryFilter"); + Set> mappingsSet = (Set>) 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 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> roiList = (List>) 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 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 sdData = sdMap.computeIfAbsent(sdUuid, k -> { + Map 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>) mcJobMap.get(mcjUuid).get("scheduleDefinition")).add(newSdData); + return newSdData; + }); + + // Add excludedDate + if (row[25] != null) { + ((Set) sdData.get("excludedDate")).add(row[25]); + } + + // Add monthlyScheduleDayOfMonthDefinition + if (row[27] != null) { + ((Set) sdData.get("monthlyScheduleDayOfMonthDefinition")).add(row[27]); + } + + // Add dateScheduleDefintion + if (row[28] != null) { + ((Set) sdData.get("dateScheduleDefintion")).add(row[28]); + } + + // Add weeklyScheduledDefinition + Map weeklyScheduledDefinition = (Map) sdData.get("weeklyScheduledDefinition"); + if (row[29] != null) { + Set> dayOfWeekRecurrence = (Set>) weeklyScheduledDefinition.computeIfAbsent("dayOfWeekRecurrence", k -> new LinkedHashSet<>()); + Map wsdData = new LinkedHashMap<>(); + wsdData.put("dates", row[29]); + dayOfWeekRecurrence.add(wsdData); + } + + // Add monthlyScheduleDayOfWeekDefinition + Map monthlyScheduleDayOfWeekDefinition = (Map) sdData.get("monthlyScheduleDayOfWeekDefinition"); + if (row[30] != null) { + monthlyScheduleDayOfWeekDefinition.put("recurringDaySequence", row[30]); + } + if (row[31] != null) { + Set> dayOfMonthRecurrence = (Set>) monthlyScheduleDayOfWeekDefinition.computeIfAbsent("dayOfMonthRecurrence", k -> new LinkedHashSet<>()); + Map 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; + } + + public MeasurementCollectionJob findMeasurementCollectionJobByUuid(String uuid){ + log.debug("MeasurementCollectionJob FIND BY UUID"); + Optional measurementCollectionJob = measurementCollectionJobRepository.findByUuid(uuid); + return measurementCollectionJob.orElse(null); + } + + public MeasurementCollectionJob createMeasurementCollectionJob(MeasurementCollectionJobFVO measurementCollectionJobFVO){ + log.debug("MeasurementCollectionJob CREATE: {}", measurementCollectionJobFVO); + + MeasurementCollectionJobMapper mapper = Mappers.getMapper(MeasurementCollectionJobMapper.class); + MeasurementCollectionJob mcj = mapper.createMeasurementCollectionJob(measurementCollectionJobFVO); + + raiseMCJCreateNotification(mcj); + + return this.measurementCollectionJobRepository.save(mcj); + } + + 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); + + this.measurementCollectionJobRepository.save(measurementCollectionJob); + + // This may be unnecessary since MeasurementCollectionJobMVO doesn't have the executionState attribute + 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; + } + + private void raiseMCJCreateNotification(MeasurementCollectionJob mcj){ + // Create the event payload + MeasurementCollectionJobRef ref = new MeasurementCollectionJobRef(); + ref.setId(mcj.getUuid()); + ref.setHref(mcj.getHref()); + + 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()); + } + + 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()); + } + + 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()); + } + + 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 0000000..a543118 --- /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 findAllPerformanceIndicatorSpecifications(){ + log.debug("PerformanceIndicatorSpecificationService: LIST"); + return (List) performanceIndicatorSpecificationRepository.findAll(); + } + + public PerformanceIndicatorSpecification findPerformanceIndicatorSpecificationByUuid(String uuid){ + log.debug("PerformanceIndicatorSpecification FIND BY UUID"); + Optional 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/util/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/util/RFC3339DateFormat.java new file mode 100644 index 0000000..357f0bb --- /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 f237167..719f8c5 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -105,6 +105,12 @@ 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 +132,10 @@ 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" #QUEUE MESSSAGES WITH VNFNSD CATALOG NFV_CATALOG_GET_NSD_BY_ID: "jms:queue:NFVCATALOG.GET.NSD_BY_ID" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6028f7f..163f1d3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -135,6 +135,12 @@ 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 +162,10 @@ 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" #QUEUE MESSSAGES WITH VNFNSD CATALOG NFV_CATALOG_GET_NSD_BY_ID: "jms:queue:NFVCATALOG.GET.NSD_BY_ID" 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 0000000..40a2697 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobApiControllerTest.java @@ -0,0 +1,249 @@ +package org.etsi.osl.services.api.pm628; + +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 mcjList = objectMapper.readValue(response, new TypeReference>() {}); + 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")); + } + + @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 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 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 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 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 0000000..d718e0a --- /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 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 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 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 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 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 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/resources/testMeasurementCollectionJobFVO.json b/src/test/resources/testMeasurementCollectionJobFVO.json new file mode 100644 index 0000000..3854d4e --- /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 -- GitLab From 69d4d296872b6d3496b7e57bb92c8f46dbfe7a43 Mon Sep 17 00:00:00 2001 From: Eduardo Santos Date: Tue, 26 Nov 2024 12:40:02 +0000 Subject: [PATCH 28/59] Addressed suggestions --- .../tmf/ram702/api/ResourceActivationApi.java | 14 +- .../api/ResourceActivationApiController.java | 65 +- .../ResourceActivationApiRouteBuilder.java | 5 +- .../repo/ResourceActivationRepository.java | 57 -- .../tmf/ram702/repo/ResourceRepository.java | 63 -- .../ResourceActivationRepoService.java | 564 ------------------ .../tmf/ram702/utils/JSONResponseUtils.java | 361 ----------- .../ResourceActivationRepoServiceTest.java | 418 ------------- .../ri639/ResourceRepoServiceTest.java | 321 ++++++++++ 9 files changed, 350 insertions(+), 1518 deletions(-) delete mode 100644 src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceActivationRepository.java delete mode 100644 src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java delete mode 100644 src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java delete mode 100644 src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java delete mode 100644 src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java create mode 100644 src/test/java/org/etsi/osl/services/reposervices/ri639/ResourceRepoServiceTest.java 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 index da9b4e7..37ef568 100644 --- a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApi.java +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApi.java @@ -50,11 +50,13 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; -import org.etsi.osl.tmf.ram702.utils.JSONResponseUtils; - @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 getObjectMapper() { @@ -100,7 +102,7 @@ public interface ResourceActivationApi { try { return new ResponseEntity<>( getObjectMapper().get().readValue( - JSONResponseUtils.RESOURCE_JSON_RESPONSE, Resource.class + RESOURCE_JSON_RESPONSE, Resource.class ), HttpStatus.NOT_IMPLEMENTED ); @@ -190,7 +192,7 @@ public interface ResourceActivationApi { try { return new ResponseEntity<>( getObjectMapper().get().readValue( - JSONResponseUtils.RESOURCE_LIST_JSON_RESPONSE, + RESOURCE_LIST_JSON_RESPONSE, new TypeReference>() {} ), HttpStatus.NOT_IMPLEMENTED @@ -244,7 +246,7 @@ public interface ResourceActivationApi { try { return new ResponseEntity<>( getObjectMapper().get().readValue( - JSONResponseUtils.RESOURCE_JSON_RESPONSE, Resource.class + RESOURCE_JSON_RESPONSE, Resource.class ), HttpStatus.NOT_IMPLEMENTED ); @@ -296,7 +298,7 @@ public interface ResourceActivationApi { try { return new ResponseEntity<>( getObjectMapper().get().readValue( - JSONResponseUtils.RESOURCE_JSON_RESPONSE, Resource.class + RESOURCE_JSON_RESPONSE, Resource.class ), 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 index 5421344..2b3cc81 100644 --- a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java @@ -30,8 +30,7 @@ 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.ram702.reposervices.ResourceActivationRepoService; - +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; @@ -52,14 +51,14 @@ import jakarta.validation.Valid; * Handles HTTP requests for creating, retrieving, updating, and deleting resources. */ @Controller -@RequestMapping("/resourceActivationManagement/v4/") +@RequestMapping("/ResourceActivationAndConfiguration/v4/") public class ResourceActivationApiController implements ResourceActivationApi { private final ObjectMapper objectMapper; private final HttpServletRequest request; @Autowired - private ResourceActivationRepoService resourceRepoService; + private ResourceRepoService resourceRepoService; /** @@ -104,7 +103,7 @@ public class ResourceActivationApiController implements ResourceActivationApi { ); Resource createdResource = resourceRepoService.addResource(resource); - return new ResponseEntity<>(createdResource, HttpStatus.CREATED); + return new ResponseEntity<>(createdResource, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } @@ -125,15 +124,12 @@ public class ResourceActivationApiController implements ResourceActivationApi { @Override public ResponseEntity deleteResource(String id) { try { - resourceRepoService.deleteByUuid(id); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } catch (ApiException e) { - log.error("Resource not found with id {}", id); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); // 404 if resource not found - } catch (Exception e) { - log.error("Error deleting resource with id {}", id, e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); // 500 for any other errors - } + + return new ResponseEntity( resourceRepoService.deleteByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } @@ -185,22 +181,9 @@ public class ResourceActivationApiController implements ResourceActivationApi { @Valid ResourceUpdate resource, String id ) { - try { - // Call the updateResource method from the service class to update the resource - Resource updatedResource = resourceRepoService.updateResource(id, resource, true); - - // Return the updated resource with 200 OK status - return new ResponseEntity<>(updatedResource, HttpStatus.OK); - - } catch (ResourceNotFoundException e) { - log.error("Resource not found with id {}", id, e); - // Return 404 Not Found if the resource is not found - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } catch (Exception e) { - log.error("Error updating resource with id {}", id, e); - // Return 500 Internal Server Error for any other unexpected exceptions - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } + Resource c = resourceRepoService.updateResource(id, resource, true); + + return new ResponseEntity< Resource >(c, HttpStatus.OK); } @@ -220,22 +203,12 @@ public class ResourceActivationApiController implements ResourceActivationApi { @Valid String fields ) { try { - // Call the service method to retrieve the resource - Resource resource = resourceRepoService.findByUuid(id); - - // Return the resource with 200 OK status - return new ResponseEntity<>(resource, HttpStatus.OK); - - } catch (ResourceNotFoundException e) { - log.error("Resource not found with id {}", id, e); - // Return 404 Not Found if the resource is not found - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - - } catch (Exception e) { - log.error("Error retrieving resource with id {}", id, e); - // Return 500 Internal Server Error for any unexpected exceptions - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } + + return new ResponseEntity( resourceRepoService.findByUuid(id), HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(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 index c556c8f..dd7dab5 100644 --- a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java @@ -34,8 +34,7 @@ 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.ram702.reposervices.ResourceActivationRepoService; - +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; @@ -63,7 +62,7 @@ public class ResourceActivationApiRouteBuilder extends RouteBuilder { private ProducerTemplate template; @Autowired - ResourceActivationRepoService resourceRepoService; + ResourceRepoService resourceRepoService; @Override public void configure() throws Exception { diff --git a/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceActivationRepository.java b/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceActivationRepository.java deleted file mode 100644 index 1cc064d..0000000 --- a/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceActivationRepository.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ========================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.repo; - -import java.util.List; -import java.util.Optional; - -import org.etsi.osl.tmf.ri639.model.Resource; - -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("resourceActivationRepository") -public interface ResourceActivationRepository extends CrudRepository, PagingAndSortingRepository { - - Optional findByUuid(String id); - - @Query( - "SELECT srv FROM RIResource srv " + - "JOIN FETCH srv.relatedParty rp " + - "WHERE rp.name = ?1" - ) - Iterable findByRolename(String name); - - @Query( - "SELECT srv FROM RIResource srv " + - "WHERE srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.AVAILABLE " + - "AND srv.endOperatingDate < CURRENT_TIMESTAMP" - ) - List findActiveToTerminate(); - - List findByNameAndResourceVersion(String aname, String aversion); - - List findByNameAndCategoryAndResourceVersion(String aname, String acategory, String aversion); -} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java b/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java deleted file mode 100644 index 9faab4d..0000000 --- a/src/main/java/org/etsi/osl/tmf/ram702/repo/ResourceRepository.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ========================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.repo; - -import java.util.List; -import java.util.Optional; - -import org.etsi.osl.tmf.ri639.model.Resource; - -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("resourceRepository702") -public interface ResourceRepository extends CrudRepository, PagingAndSortingRepository { - - - Optional findByUuid(String id); - - @Query("SELECT srv FROM RIResource srv JOIN FETCH srv.relatedParty rp WHERE rp.name = ?1") - Iterable findByRolename(String name); - - - @Query("SELECT srv FROM RIResource srv WHERE srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.AVAILABLE AND " - + "srv.endOperatingDate < CURRENT_TIMESTAMP") - List findActiveToTerminate(); - - @Query("SELECT srv FROM RIResource srv " - + "JOIN FETCH srv.resourceCharacteristic char " - + "JOIN FETCH char.value val " - + "WHERE (srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.AVAILABLE OR " - + " srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.RESERVED OR " - + " srv.resourceStatus = org.etsi.osl.tmf.ri639.model.ResourceStatusType.STANDBY) AND " - + "char.name = 'externalPartnerServiceId'" - ) - - List findActiveAndReservedResourcesOfPartners(); - - - List findByNameAndResourceVersion(String aname, String aversion); - List findByNameAndCategoryAndResourceVersion(String aname, String acategory, String aversion); -} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java b/src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java deleted file mode 100644 index 88d04f9..0000000 --- a/src/main/java/org/etsi/osl/tmf/ram702/reposervices/ResourceActivationRepoService.java +++ /dev/null @@ -1,564 +0,0 @@ -/*- - * ========================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.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.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -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.ram702.api.ApiException; -import org.etsi.osl.tmf.common.model.Any; -import org.etsi.osl.tmf.common.model.UserPartRoleType; -import org.etsi.osl.tmf.common.model.service.Note; -import org.etsi.osl.tmf.prm669.model.RelatedParty; -import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; -import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; -import org.etsi.osl.tmf.ram702.api.ResourceActivationApiRouteBuilderEvents; -import org.etsi.osl.tmf.ram702.api.ResourceNotFoundException; -import org.etsi.osl.tmf.ri639.model.Characteristic; -import org.etsi.osl.tmf.ri639.model.Feature; -import org.etsi.osl.tmf.ri639.model.LogicalResource; -import org.etsi.osl.tmf.ri639.model.PhysicalResource; -import org.etsi.osl.tmf.ri639.model.Resource; -import org.etsi.osl.tmf.ri639.model.ResourceAttributeValueChangeEvent; -import org.etsi.osl.tmf.ri639.model.ResourceAttributeValueChangeNotification; -import org.etsi.osl.tmf.ri639.model.ResourceCreate; -import org.etsi.osl.tmf.ri639.model.ResourceCreateEvent; -import org.etsi.osl.tmf.ri639.model.ResourceCreateNotification; -import org.etsi.osl.tmf.ri639.model.ResourceRelationship; -import org.etsi.osl.tmf.ri639.model.ResourceStateChangeEvent; -import org.etsi.osl.tmf.ri639.model.ResourceStateChangeNotification; -import org.etsi.osl.tmf.ri639.model.ResourceUpdate; -import org.etsi.osl.tmf.ram702.repo.ResourceActivationRepository; - -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.Transactional; -import jakarta.persistence.EntityManagerFactory; -import jakarta.validation.Valid; - -/** - * Service class for managing Resource Activation operations. - * Provides methods to add, update, delete, and retrieve resources. - */ -@org.springframework.stereotype.Service -public class ResourceActivationRepoService { - - private static final transient Log logger = - LogFactory.getLog(ResourceActivationRepoService.class.getName()); - - @Autowired - ObjectMapper objectMapper; - - @Autowired - ResourceActivationRepository resourceRepo; - - @Autowired - ResourceSpecificationRepoService resourceSpecRepoService; - - private SessionFactory sessionFactory; - - @Autowired - ResourceActivationApiRouteBuilderEvents resourceApiRouteBuilder; - - - /** - * Constructs the ResourceActivationRepoService with the given EntityManagerFactory. - * - * @param factory the EntityManagerFactory to use - */ - @Autowired - public ResourceActivationRepoService(EntityManagerFactory factory) { - if (factory.unwrap(SessionFactory.class) == null) { - throw new NullPointerException("factory is not a hibernate factory"); - } - this.sessionFactory = factory.unwrap(SessionFactory.class); - } - - - /** - * Retrieves all resources from the repository. - * - * @return a list of all resources - */ - public List findAll() { - - return (List) this.resourceRepo.findAll(); - } - - /** - * Finds resources by name and requester role. - * - * @param name the name of the resource - * @param requester the requester role - * @return a list of resources matching the name and requester role - */ - public List findAll(String name, UserPartRoleType requester) { - - return (List) this.resourceRepo.findByRolename(name); - } - - - /** - * Adds a new resource to the repository. - * - * @param resource the resource to add - * @return the added resource - */ - public Resource addResource(@Valid ResourceCreate resource){ - logger.info("Will add Resource: " + resource.getName()); - - Resource s; - - if (resource.getAtType() != null - && resource.getAtType().toLowerCase().contains("physicalresource")) { - s = new PhysicalResource(); - } else { - s = new LogicalResource(); - } - - if (resource.getAtType() != null) { - s.setType(resource.getAtType()); - } - s.setName(resource.getName()); - s.setCategory(resource.getCategory()); - s.setDescription(resource.getDescription()); - - if ( resource.getStartOperatingDate() == null ) { - s.setStartOperatingDate(OffsetDateTime.now(ZoneOffset.UTC)); - } else { - s.setStartOperatingDate(resource.getStartOperatingDate()); - } - s.setEndOperatingDate(resource.getEndOperatingDate()); - s.setUsageState(resource.getUsageState()); - s.setResourceStatus(resource.getResourceStatus()); - s.setResourceVersion(resource.getResourceVersion()); - s.setOperationalState(resource.getOperationalState()); - s.setAdministrativeState(resource.getAdministrativeState()); - - ResourceSpecificationRef thespecRef = new ResourceSpecificationRef(); - thespecRef.setId(resource.getResourceSpecification().getId()); - thespecRef.setName(resource.getResourceSpecification().getName()); - - s.setResourceSpecification(thespecRef); - - if (resource.getPlace() != null) { - s.setPlace(resource.getPlace()); - } - if (resource.getNote() != null) { - s.getNote().addAll(resource.getNote()); - } - if (resource.getRelatedParty() != null) { - s.getRelatedParty().addAll(resource.getRelatedParty()); - } - if (resource.getResourceCharacteristic() != null) { - s.getResourceCharacteristic().addAll(resource.getResourceCharacteristic()); - } - if (resource.getResourceRelationship() != null) { - s.getResourceRelationship().addAll(resource.getResourceRelationship()); - } - if (resource.getAttachment() != null) { - s.getAttachment().addAll(resource.getAttachment()); - } - if (resource.getActivationFeature() != null) { - s.getActivationFeature().addAll(resource.getActivationFeature()); - } - - Note noteItem = new Note(); - noteItem.setText("Resource status: " + s.getResourceStatus()); - noteItem.setAuthor("API"); - noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC)); - s.addNoteItem(noteItem); - - s = this.resourceRepo.save(s); - - raiseResourceCreateNotification(s); - return s; - } - - - /** - * Finds a resource by its UUID. - * - * @param id the UUID of the resource - * @return the resource if found, or null if not found - */ - @Transactional - public Resource findByUuid(String id) throws ResourceNotFoundException { - Optional optionalCat = this.resourceRepo.findByUuid(id); - - if (optionalCat.isEmpty()) { - throw new ResourceNotFoundException("Resource not found with UUID: " + id); - } - - return optionalCat.get(); - } - - - /** - * Updates an existing resource with the given updates. - * - * @param id the UUID of the resource to update - * @param resourceUpd the resource update data - * @param triggerServiceActionQueue whether to trigger service action queue - * @return the updated resource - */ - @Transactional - public Resource updateResource(String id, @Valid ResourceUpdate resourceUpd, - boolean triggerServiceActionQueue) throws ResourceNotFoundException { - Resource resource = this.getResourceEager(id); - - if (resource == null) { - throw new ResourceNotFoundException("Resource not found with UUID: " + id); - } - - logger.info("Will update Resource: " + resource.getName()); - - if (resourceUpd.getResourceRelationship() != null) { - resource.setResourceRelationship( - new LinkedHashSet(resourceUpd.getResourceRelationship() - )); - } - - if (resourceUpd.getAtType() != null) { - resource.setType(resourceUpd.getAtType()); - } - if (resourceUpd.getName() != null) { - resource.setName(resourceUpd.getName()); - } - if (resourceUpd.getCategory() != null) { - resource.setCategory(resourceUpd.getCategory()); - } - if (resourceUpd.getDescription() != null) { - resource.setDescription(resourceUpd.getDescription()); - } - if (resourceUpd.getStartOperatingDate() != null) { - resource.setStartOperatingDate(resourceUpd.getStartOperatingDate()); - } - if (resourceUpd.getEndOperatingDate() != null) { - resource.setEndOperatingDate(resourceUpd.getEndOperatingDate()); - } - if (resourceUpd.getUsageState() != null) { - resource.setUsageState(resourceUpd.getUsageState()); - } - - boolean resourceStateChanged = false; - if (resourceUpd.getResourceStatus() != null) { - if (!resourceUpd.getResourceStatus().equals(resource.getResourceStatus())) { - resourceStateChanged = true; - } - - resource.setResourceStatus(resourceUpd.getResourceStatus()); - } - if (resourceUpd.getResourceVersion() != null) { - resource.setResourceVersion(resourceUpd.getResourceVersion()); - } - if (resourceUpd.getOperationalState() != null) { - resource.setOperationalState(resourceUpd.getOperationalState()); - } - if (resourceUpd.getAdministrativeState() != null) { - resource.setAdministrativeState(resourceUpd.getAdministrativeState()); - } - if (resourceUpd.getResourceSpecification() != null) { - resource.setResourceSpecification(resourceUpd.getResourceSpecification()); - } - - if (resourceUpd.getPlace() != null) { - resource.setPlace(resourceUpd.getPlace()); - } - - if (resourceUpd.getNote() != null) { - for (Note n : resourceUpd.getNote()) { - if (n.getUuid() == null) { - resource.addNoteItem(n); - } - } - } - - if (resourceUpd.getRelatedParty() != null) { - for (RelatedParty n : resourceUpd.getRelatedParty()) { - if (n.getUuid() == null) { - resource.addRelatedPartyItem(n); - } - } - } - - boolean resourceCharacteristicChanged = false; - String charsChanged=""; - if (resourceUpd.getResourceCharacteristic() != null) { - for (Characteristic n : resourceUpd.getResourceCharacteristic()) { - - if (resource.getResourceCharacteristicByName(n.getName()) != null) { - - Characteristic origChar = resource.getResourceCharacteristicByName(n.getName()); - if ((origChar != null) && (origChar.getValue() != null) && (origChar.getValue().getValue() != null)) { - if (!origChar.getValue().getValue().equals(n.getValue().getValue())) { - resourceCharacteristicChanged = true; - charsChanged = charsChanged + n.getName() + ","; - } - } - - resource.getResourceCharacteristicByName(n.getName()) - .setValue(new Any(n.getValue().getValue(), n.getValue().getAlias())); - } else { - resource.addResourceCharacteristicItem(n); - resourceCharacteristicChanged = true; - charsChanged = charsChanged + n.getName() + ","; - } - } - } - - if (resourceCharacteristicChanged) { - Note n = new Note(); - n.setText("Resource characteristics changed : " + charsChanged); - n.setAuthor( "RAM702-API" ); - n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); - resource.addNoteItem( n ); - - } - - if (resourceStateChanged) { - Note n = new Note(); - n.setText("Resource resourceStateChanged changed to " + resource.getResourceStatus().toString() ); - n.setAuthor( "RAM702-API" ); - n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); - resource.addNoteItem( n ); - - } - - if (resourceUpd.getActivationFeature() != null) { - for (Feature n : resourceUpd.getActivationFeature()) { - if (n.getId() != null) { - // we need to update this ? - } else { - resource.getActivationFeature().add(n); - } - - } - } - - resource = this.resourceRepo.save(resource); - - if (resourceCharacteristicChanged) { - raiseResourceAttributeValueChangeEventNotification(resource); - } else if (resourceStateChanged) { - raiseResourceStateChangeEventNotification(resource); - } - return resource; - } - - /** - * Retrieves a resource by UUID and returns it as a JSON string. - * - * @param id the UUID of the resource - * @return the resource as a JSON string - * @throws JsonProcessingException if JSON processing fails - * @throws ResourceNotFoundException if Resource not found - */ - public String getResourceEagerAsString(String id) throws JsonProcessingException, ResourceNotFoundException { - Resource s = this.getResourceEager(id); - ObjectMapper mapper = new ObjectMapper(); - mapper.registerModule(new Hibernate5JakartaModule()); - String res = mapper.writeValueAsString(s); - - return res; - } - - - /** - * Retrieves a resource by UUID with all associations eagerly loaded. - * - * @param id the UUID of the resource - * @return the resource with all associations initialized - * @throws ResourceNotFoundException if Resource not found - */ - public Resource getResourceEager(String id) throws ResourceNotFoundException { - Session session = sessionFactory.openSession(); - Transaction tx = session.beginTransaction(); - Resource s = null; - try { - s = (Resource) session.get(Resource.class, id); - if (s == null) { - return this.findByUuid(id); - } - - Hibernate.initialize(s.getRelatedParty()); - Hibernate.initialize(s.getNote()); - Hibernate.initialize(s.getResourceCharacteristic()); - Hibernate.initialize(s.getResourceSpecification()); - Hibernate.initialize(s.getResourceRelationship()); - Hibernate.initialize(s.getAttachment()); - Hibernate.initialize(s.getActivationFeature()); - - tx.commit(); - } finally { - session.close(); - } - - return s; - } - - - /** - * Raises a resource create notification event. - * - * @param so the resource that was created - */ - @Transactional - private void raiseResourceCreateNotification(Resource so) { - ResourceCreateNotification n = new ResourceCreateNotification(); - ResourceCreateEvent event = new ResourceCreateEvent(); - event.getEvent().setResource(so); - n.setEvent(event); - resourceApiRouteBuilder.publishEvent(n, so.getId()); - - } - - - /** - * Raises a resource attribute value change notification event. - * - * @param so the resource that has changed - */ - @Transactional - private void raiseResourceAttributeValueChangeEventNotification(Resource so) { - ResourceAttributeValueChangeNotification n = new ResourceAttributeValueChangeNotification(); - ResourceAttributeValueChangeEvent event = new ResourceAttributeValueChangeEvent(); - event.getEvent().setResource(so); - n.setEvent(event); - resourceApiRouteBuilder.publishEvent(n, so.getId()); - - } - - - /** - * Raises a resource state change notification event. - * - * @param so the resource whose state has changed - */ - @Transactional - private void raiseResourceStateChangeEventNotification(Resource so) { - ResourceStateChangeNotification n = new ResourceStateChangeNotification(); - ResourceStateChangeEvent event = new ResourceStateChangeEvent(); - event.getEvent().setResource(so); - n.setEvent(event); - resourceApiRouteBuilder.publishEvent(n, so.getId()); - - } - - - /** - * Finds all active resources that need to be terminated. - * - * @return a list of resource UUIDs to terminate - */ - @Transactional - public List findAllActiveResourcesToTerminate() { - - List result = new ArrayList<>(); - List resourcs = this.resourceRepo.findActiveToTerminate(); - for (Resource r : resourcs) { - result.add(r.getId()); - } - - return result; - } - - - /** - * Deletes a resource by its UUID. - * - * @param id the UUID of the resource to delete - * @return null - * @throws ApiException - */ - public Void deleteByUuid(String id) throws ApiException { - Optional optionalCat = this.resourceRepo.findByUuid(id); - - if (optionalCat.isPresent()) { - Resource s = optionalCat.get(); - this.resourceRepo.delete(s); - - logger.info("Deleted resource with UUID = " + id); - } else { - throw new ApiException(404, "Resource not found with UUID: " + id); - } - - return null; - } - - - /** - * Adds a new resource or updates an existing one based on name, category, and version. - * - * @param aName the name of the resource - * @param aCategory the category of the resource - * @param aVersion the version of the resource - * @param resourceCreate the resource data to create or update - * @return the added or updated resource - */ - @Transactional - public Resource addOrUpdateResourceByNameCategoryVersion(String aName, String aCategory, - String aVersion, ResourceCreate aResourceCreate) throws ApiException { - - List resources = - this.resourceRepo.findByNameAndCategoryAndResourceVersion(aName, aCategory, aVersion); - Resource result = null; - - if (resources.size() > 0) { - // perform update to the first one - String resID = resources.get(0).getUuid(); - result = this.updateResource(resID, aResourceCreate, false); - - } else { - result = this.addResource(aResourceCreate); - } - - ObjectMapper mapper = new ObjectMapper(); - try { - String originaServiceAsJson = mapper.writeValueAsString(result); - logger.debug(originaServiceAsJson); - } catch (JsonProcessingException e) { - logger.error("cannot umarshall service: " + result.getName()); - e.printStackTrace(); - } - - return result; - } -} diff --git a/src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java b/src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java deleted file mode 100644 index 9573c27..0000000 --- a/src/main/java/org/etsi/osl/tmf/ram702/utils/JSONResponseUtils.java +++ /dev/null @@ -1,361 +0,0 @@ -package org.etsi.osl.tmf.ram702.utils; - -public class JSONResponseUtils { - public static final String RESOURCE_JSON_RESPONSE = "{\\r\\n" + // - " \\\"note\\\" : [ {\\r\\n" + // - " \\\"date\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"author\\\" : \\\"author\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"text\\\" : \\\"text\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"date\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"author\\\" : \\\"author\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"text\\\" : \\\"text\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"endOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"resourceVersion\\\" : \\\"resourceVersion\\\",\\r\\n" + // - " \\\"activationFeature\\\" : [ {\\r\\n" + // - " \\\"isBundle\\\" : true,\\r\\n" + // - " \\\"isEnabled\\\" : true,\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"featureCharacteristic\\\" : [ {\\r\\n" + // - " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"value\\\" : { }\\r\\n" + // - " }, {\\r\\n" + // - " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"value\\\" : { }\\r\\n" + // - " } ],\\r\\n" + // - " \\\"constraint\\\" : [ {\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"version\\\" : \\\"version\\\"\\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\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"version\\\" : \\\"version\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"featureRelationship\\\" : [ {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"validFor\\\" : {\\r\\n" + // - " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // - " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"validFor\\\" : {\\r\\n" + // - " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // - " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\"\\r\\n" + // - " } ]\\r\\n" + // - " }, {\\r\\n" + // - " \\\"isBundle\\\" : true,\\r\\n" + // - " \\\"isEnabled\\\" : true,\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"featureCharacteristic\\\" : [ {\\r\\n" + // - " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"value\\\" : { }\\r\\n" + // - " }, {\\r\\n" + // - " \\\"characteristicRelationship\\\" : [ {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"valueType\\\" : \\\"valueType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"value\\\" : { }\\r\\n" + // - " } ],\\r\\n" + // - " \\\"constraint\\\" : [ {\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"version\\\" : \\\"version\\\"\\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\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"version\\\" : \\\"version\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"featureRelationship\\\" : [ {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"validFor\\\" : {\\r\\n" + // - " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // - " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"relationshipType\\\",\\r\\n" + // - " \\\"validFor\\\" : {\\r\\n" + // - " \\\"startDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\",\\r\\n" + // - " \\\"endDateTime\\\" : \\\"1985-04-12T23:20:50.52Z\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\"\\r\\n" + // - " } ]\\r\\n" + // - " } ],\\r\\n" + // - " \\\"description\\\" : \\\"description\\\",\\r\\n" + // - " \\\"resourceCharacteristic\\\" : [ null, null ],\\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\\\" : \\\"http://example.com/aeiou\\\",\\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\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"attachment\\\" : [ {\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"attachmentType\\\" : \\\"video\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"description\\\" : \\\"Photograph of the Product\\\",\\r\\n" + // - " \\\"mimeType\\\" : \\\"mimeType\\\",\\r\\n" + // - " \\\"content\\\" : \\\"content\\\",\\r\\n" + // - " \\\"url\\\" : \\\"http://host/Content/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // - " \\\"size\\\" : {\\r\\n" + // - " \\\"amount\\\" : 0.8008282,\\r\\n" + // - " \\\"units\\\" : \\\"units\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://host/Attachment/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"attachmentType\\\" : \\\"video\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"description\\\" : \\\"Photograph of the Product\\\",\\r\\n" + // - " \\\"mimeType\\\" : \\\"mimeType\\\",\\r\\n" + // - " \\\"content\\\" : \\\"content\\\",\\r\\n" + // - " \\\"url\\\" : \\\"http://host/Content/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // - " \\\"size\\\" : {\\r\\n" + // - " \\\"amount\\\" : 0.8008282,\\r\\n" + // - " \\\"units\\\" : \\\"units\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://host/Attachment/4aafacbd-11ff-4dc8-b445-305f2215715f\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"administrativeState\\\" : \\\"locked\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"resourceRelationship\\\" : [ {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"bundled\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"resource\\\" : {\\r\\n" + // - " \\\"note\\\" : [ null, null ],\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"endOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"resourceVersion\\\" : \\\"resourceVersion\\\",\\r\\n" + // - " \\\"activationFeature\\\" : [ null, null ],\\r\\n" + // - " \\\"resourceSpecification\\\" : {\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"version\\\" : \\\"version\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"description\\\" : \\\"description\\\",\\r\\n" + // - " \\\"resourceCharacteristic\\\" : [ null, null ],\\r\\n" + // - " \\\"relatedParty\\\" : [ null, null ],\\r\\n" + // - " \\\"resourceStatus\\\" : \\\"standby\\\",\\r\\n" + // - " \\\"usageState\\\" : \\\"idle\\\",\\r\\n" + // - " \\\"attachment\\\" : [ null, null ],\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"resourceRelationship\\\" : [ null, null ],\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"href\\\",\\r\\n" + // - " \\\"startOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"category\\\" : \\\"category\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " }, {\\r\\n" + // - " \\\"relationshipType\\\" : \\\"bundled\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"resource\\\" : {\\r\\n" + // - " \\\"note\\\" : [ null, null ],\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"endOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"resourceVersion\\\" : \\\"resourceVersion\\\",\\r\\n" + // - " \\\"activationFeature\\\" : [ null, null ],\\r\\n" + // - " \\\"resourceSpecification\\\" : {\\r\\n" + // - " \\\"@referredType\\\" : \\\"@referredType\\\",\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"version\\\" : \\\"version\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"description\\\" : \\\"description\\\",\\r\\n" + // - " \\\"resourceCharacteristic\\\" : [ null, null ],\\r\\n" + // - " \\\"relatedParty\\\" : [ null, null ],\\r\\n" + // - " \\\"resourceStatus\\\" : \\\"standby\\\",\\r\\n" + // - " \\\"usageState\\\" : \\\"idle\\\",\\r\\n" + // - " \\\"attachment\\\" : [ null, null ],\\r\\n" + // - " \\\"@baseType\\\" : \\\"@baseType\\\",\\r\\n" + // - " \\\"name\\\" : \\\"name\\\",\\r\\n" + // - " \\\"resourceRelationship\\\" : [ null, null ],\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"href\\\",\\r\\n" + // - " \\\"startOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"category\\\" : \\\"category\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " },\\r\\n" + // - " \\\"@type\\\" : \\\"@type\\\",\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"http://example.com/aeiou\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - " } ],\\r\\n" + // - " \\\"id\\\" : \\\"id\\\",\\r\\n" + // - " \\\"href\\\" : \\\"href\\\",\\r\\n" + // - " \\\"startOperatingDate\\\" : \\\"2000-01-23T04:56:07.000+00:00\\\",\\r\\n" + // - " \\\"operationalState\\\" : \\\"enable\\\",\\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" + // - " \\\"category\\\" : \\\"category\\\",\\r\\n" + // - " \\\"@schemaLocation\\\" : \\\"http://example.com/aeiou\\\"\\r\\n" + // - "}"; - - public static final String RESOURCE_LIST_JSON_RESPONSE = "[" + RESOURCE_JSON_RESPONSE + "]"; -} diff --git a/src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java b/src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java deleted file mode 100644 index 5703507..0000000 --- a/src/test/java/org/etsi/osl/services/reposervices/ram702/ResourceActivationRepoServiceTest.java +++ /dev/null @@ -1,418 +0,0 @@ -package org.etsi.osl.services.reposervices.ram702; - -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.ram702.api.ApiException; -import org.etsi.osl.tmf.ram702.api.ResourceNotFoundException; -import org.etsi.osl.tmf.ram702.repo.ResourceActivationRepository; -import org.etsi.osl.tmf.ram702.reposervices.ResourceActivationRepoService; -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.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -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 ResourceActivationRepoService}. - * - * This class uses Mockito and Spring's testing framework to mock dependencies - * and verify the behavior of the ResourceActivationRepoService. - */ -@RunWith(SpringRunner.class) -@ActiveProfiles("testing") -@SpringBootTest(classes = OpenAPISpringBoot.class) -public class ResourceActivationRepoServiceTest { - /** - * The service being tested, with a spy to allow partial mocking of certain methods. - */ - @SpyBean - @Autowired - private ResourceActivationRepoService resourceActivationRepoService; - - /** - * Mock for the {@link ResourceActivationRepository} to simulate repository operations. - */ - @MockBean - private ResourceActivationRepository resourceActivationRepo; - - 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() throws ResourceNotFoundException { - when(resourceActivationRepo.findByUuid(anyString())).thenReturn(Optional.of(resource)); - when(resourceActivationRepo.save(any(Resource.class))).thenReturn(resource); - doReturn(resource).when(resourceActivationRepoService).getResourceEager(anyString()); - } - - /** - * Test for {@link ResourceActivationRepoService#findByUuid(String)} when a resource is found. - * - * @throws ResourceNotFoundException if the resource is not found (not expected). - */ - @Test - public void testFindByUuidWhenResourceIsFound() throws ResourceNotFoundException { - // When - Resource result = resourceActivationRepoService.findByUuid(anyString()); - - // Then - assertNotNull(result); - verify(resourceActivationRepo, times(1)).findByUuid(anyString()); - } - - /** - * Test for {@link ResourceActivationRepoService#findByUuid(String)} when no resource is found. - * This ensures that a {@link ResourceNotFoundException} is thrown when the resource does not exist. - * - * @throws ResourceNotFoundException expected exception if the resource is not found. - */ - @Test - public void testFindByUuidWhenResourceIsNotFound() throws ResourceNotFoundException { - // Given - when(resourceActivationRepo.findByUuid(anyString())).thenReturn(Optional.empty()); - - // When - ResourceNotFoundException exception = assertThrows(ResourceNotFoundException.class, () -> { - resourceActivationRepoService.findByUuid("123"); - }); - - // Then - assertEquals("Resource not found with UUID: 123", exception.getMessage()); - } - - /** - * Test for {@link ResourceActivationRepoService#findAll()} to verify it retrieves all resources. - */ - @Test - public void testFindAllResources() { - // Given - List 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(resourceActivationRepo.findAll()).thenReturn(resources); - - // When - List result = resourceActivationRepoService.findAll(); - - // Then - assertNotNull(result); - assertEquals(2, result.size()); - assertEquals("resource1", result.get(0).getName()); - assertEquals("resource2", result.get(1).getName()); - verify(resourceActivationRepo, times(1)).findAll(); - } - - /** - * Test for {@link ResourceActivationRepoService#addResource(ResourceCreate)} to verify resource creation. - */ - @Test - public void testAddResource() { - // When - Resource result = resourceActivationRepoService.addResource(resourceCreate); - - // Then - assertNotNull(result); - assertEquals("test_resource", result.getName()); - verify(resourceActivationRepo, times(1)).save(any(Resource.class)); - } - - /** - * Test for {@link ResourceActivationRepoService#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() throws ResourceNotFoundException{ - 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 = resourceActivationRepoService.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(resourceActivationRepo, times(1)).save(any(Resource.class)); - } - - /** - * Test for {@link ResourceActivationRepoService#updateResource(String, ResourceUpdate, boolean)} - * to verify that a {@link ResourceNotFoundException} is thrown when the resource does not exist. - * @throws ResourceNotFoundException - */ - @Test - public void testUpdateResourceWhenResourceIsNotFound() throws ResourceNotFoundException { - // Given - doReturn(null).when(resourceActivationRepoService).getResourceEager(anyString()); - ResourceUpdate update = new ResourceUpdate(); - - // When - ResourceNotFoundException exception = assertThrows(ResourceNotFoundException.class, () -> { - resourceActivationRepoService.updateResource("123", update, false); - }); - - // Then - assertEquals("Resource not found with UUID: 123", exception.getMessage()); - verify(resourceActivationRepo, never()).save(any(Resource.class)); - } - - /** - * Test for {@link ResourceActivationRepoService#deleteByUuid(String)} to verify successful resource deletion. - * - * @throws ApiException if there is an error during the deletion process (not expected). - */ - @Test - public void testDeleteByUuidWhenResourceIsFound() throws ApiException { - // When - resourceActivationRepoService.deleteByUuid("123"); - - // Then - verify(resourceActivationRepo, times(1)).delete(resource); - } - - /** - * Test for {@link ResourceActivationRepoService#deleteByUuid(String)} to verify that an {@link ApiException} - * is thrown when the resource to delete is not found. - */ - @Test - public void testDeleteByUuidWhenResourceIsNotFound() { - // Given - when(resourceActivationRepo.findByUuid("123")).thenReturn(Optional.empty()); - - // When - ApiException exception = assertThrows(ApiException.class, () -> { - resourceActivationRepoService.deleteByUuid("123"); - }); - - // Then - assertEquals("Resource not found with UUID: 123", exception.getMessage()); - verify(resourceActivationRepo, never()).delete(any(Resource.class)); - } - - /** - * Test for {@link ResourceActivationRepoService#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() throws ApiException { - // Given - ResourceUpdate update = new ResourceUpdate(); - update.setName("updated_name"); - - String name = "test_resource"; - String category = "Category 1"; - String version = "1.0"; - - List existingResources = Collections.singletonList(resource); - - // Mock the repository to return the existing resource - when(resourceActivationRepo.findByNameAndCategoryAndResourceVersion(anyString(), anyString(), anyString())) - .thenReturn(existingResources); - - // Mock the updateResource method to return the updated resource - when(resourceActivationRepoService.updateResource("123", update, false)) - .thenReturn(resource); - - // When - Resource result = resourceActivationRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); - - // Then - assertNotNull(result); - assertEquals("test_resource", result.getName()); - verify(resourceActivationRepoService, times(1)).updateResource("123", update, false); - } - - /** - * Test for {@link ResourceActivationRepoService#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() throws ApiException { - // Given - String name = "test_resource"; - String category = "Category 1"; - String version = "1.0"; - - // Mock an empty list of existing resources - List noResources = new ArrayList<>(); - - // Mock the repository to return no existing resources - when(resourceActivationRepo.findByNameAndCategoryAndResourceVersion(anyString(), anyString(), anyString())) - .thenReturn(noResources); - - // Mock the addResource method to return the newly created resource - when(resourceActivationRepoService.addResource(resourceCreate)).thenReturn(resource); - - // When - Resource result = resourceActivationRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); - - // Then - assertNotNull(result); - assertEquals("test_resource", result.getName()); - verify(resourceActivationRepoService, times(1)).addResource(any(ResourceCreate.class)); - verify(resourceActivationRepoService, never()).updateResource(result.getId(), resourceCreate, false); - } - - /** - * Test for {@link ResourceActivationRepoService#addOrUpdateResourceByNameCategoryVersion(String, String, String, ResourceCreate)} - * to handle an {@link ApiException} being thrown during the process. - * - * @throws ApiException expected exception during the process. - */ - @Test - public void testAddOrUpdateResourceByNameCategoryVersionThrowsApiException() throws ApiException { - // Given - String name = "Faulty Resource"; - String category = "Faulty Category"; - String version = "1.0"; - - // Mock an existing resource - List existingResources = Collections.singletonList(resource); - - // Mock the repository to return the existing resource - when(resourceActivationRepo.findByNameAndCategoryAndResourceVersion(name, category, version)) - .thenReturn(existingResources); - - // Mock the updateResource method to throw an ApiException - doThrow(new ResourceNotFoundException("Error updating resource")) - .when(resourceActivationRepoService).updateResource(resource.getId(), resourceCreate, false); - - // When and Then - ApiException exception = assertThrows(ApiException.class, () -> { - resourceActivationRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, resourceCreate); - }); - - assertEquals("Error updating resource", exception.getMessage()); - verify(resourceActivationRepoService, times(1)).updateResource(resource.getId(), resourceCreate, false); - verify(resourceActivationRepoService, never()).addResource(resourceCreate); // Add should not be called - } - - /** - * Test for {@link ResourceActivationRepoService#raiseResourceAttributeValueChangeEventNotification(Resource)} - * to ensure a resource attribute value change notification is published. - */ - @Test - public void testFindAllActiveResourcesToTerminate() { - // Given - List resources = new ArrayList<>(); - Resource resource1 = mock(Resource.class); - when(resource1.getId()).thenReturn("uuid1"); - resources.add(resource1); - - when(resourceActivationRepo.findActiveToTerminate()).thenReturn(resources); - - // When - List result = resourceActivationRepoService.findAllActiveResourcesToTerminate(); - - // Then - assertNotNull(result); - assertEquals(1, result.size()); - assertEquals("uuid1", result.get(0)); - verify(resourceActivationRepo, times(1)).findActiveToTerminate(); - } -} 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 0000000..8100820 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/reposervices/ri639/ResourceRepoServiceTest.java @@ -0,0 +1,321 @@ +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); + 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 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 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)).save(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)).save(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 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 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 resources = new ArrayList<>(); + Resource resource1 = mock(Resource.class); + when(resource1.getId()).thenReturn("uuid1"); + resources.add(resource1); + + when(resourceRepo.findActiveToTerminate()).thenReturn(resources); + + // When + List result = resourceRepoService.findAllActiveResourcesToTerminate(); + + // Then + assertNotNull(result); + assertEquals(1, result.size()); + assertEquals("uuid1", result.get(0)); + verify(resourceRepo, times(1)).findActiveToTerminate(); + } +} -- GitLab From 154c511a3c2354c0618e37fcbf8ecf6249f59a4b Mon Sep 17 00:00:00 2001 From: Kostis Trantzas Date: Tue, 26 Nov 2024 21:28:46 +0200 Subject: [PATCH 29/59] Added swagger documentation entry and camelcase at API's route --- .../SwaggerDocumentationConfig.java | 34 +++++++++++++++++++ .../api/ResourceActivationApiController.java | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) 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 d9433a3..ac55f12 100644 --- a/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java +++ b/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java @@ -877,6 +877,40 @@ public class SwaggerDocumentationConfig { .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/ram702/api/ResourceActivationApiController.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java index 2b3cc81..30b703e 100644 --- a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiController.java @@ -51,7 +51,7 @@ import jakarta.validation.Valid; * Handles HTTP requests for creating, retrieving, updating, and deleting resources. */ @Controller -@RequestMapping("/ResourceActivationAndConfiguration/v4/") +@RequestMapping("/resourceActivationAndConfiguration/v4/") public class ResourceActivationApiController implements ResourceActivationApi { private final ObjectMapper objectMapper; -- GitLab From ddc4105e9bd00c6219874f35bdad131c0226ff5a Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 27 Nov 2024 17:56:57 +0200 Subject: [PATCH 30/59] fix for merge --- pom.xml | 2 +- src/main/resources/application-testing.yml | 13 ++++++------- src/main/resources/application.yml | 14 ++++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index cd2166e..53e828a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,11 +9,11 @@ ../org.etsi.osl.main + ${org.etsi.osl.tmf.api.version>} org.etsi.osl.tmf.api org.etsi.osl.tmf.api - ${org.etsi.osl.tmf.api.version>} diff --git a/src/main/resources/application-testing.yml b/src/main/resources/application-testing.yml index 4e908f4..1c966ea 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -94,7 +94,12 @@ 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" @@ -112,12 +117,6 @@ 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" -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" #ALARMS ALARMS_ADD_ALARM: "jms:queue:ALARMS.ADD.ALARM" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index db294fe..33b6f60 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -122,8 +122,12 @@ 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" @@ -141,12 +145,6 @@ 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" -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" #ALARMS -- GitLab From d6bfc02d33f5d6c2eb888461753894eae38bc290 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 27 Nov 2024 18:09:57 +0200 Subject: [PATCH 31/59] fix pom.xml --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 14e3f3e..56e5a62 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,6 @@ org.etsi.osl.tmf.api org.etsi.osl.tmf.api - ${org.etsi.osl.tmf.api.version} OpenSlice by ETSI -- GitLab From ed313f01a4afddb48a13576e12f9402b31966e10 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 27 Nov 2024 18:10:07 +0200 Subject: [PATCH 32/59] fix hubapi controllers --- src/main/java/org/etsi/osl/tmf/pim637/api/HubApiController.java | 2 +- src/main/java/org/etsi/osl/tmf/pm628/api/HubApiController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 index 19e6954..96129c8 100644 --- a/src/main/java/org/etsi/osl/tmf/pim637/api/HubApiController.java +++ b/src/main/java/org/etsi/osl/tmf/pim637/api/HubApiController.java @@ -18,7 +18,7 @@ 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 +@RestController("HubApiController637") public class HubApiController implements HubApi { private static final Logger log = LoggerFactory.getLogger(HubApiController.class); 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 index 77be4ef..c3bf28d 100644 --- a/src/main/java/org/etsi/osl/tmf/pm628/api/HubApiController.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/HubApiController.java @@ -9,7 +9,7 @@ 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 +@Controller("HubApiController628") @RequestMapping("/performance/v5") public class HubApiController implements HubApi { -- GitLab From 14aacb627dc2f08f20dd94352ec36cd13adb147d Mon Sep 17 00:00:00 2001 From: trantzas Date: Wed, 27 Nov 2024 17:44:06 +0000 Subject: [PATCH 33/59] Fix pipeline failures (#49) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 56e5a62..1d671cd 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ ../org.etsi.osl.main - ${org.etsi.osl.tmf.api.version>} + ${org.etsi.osl.tmf.api.version} org.etsi.osl.tmf.api org.etsi.osl.tmf.api -- GitLab From f5a5732287efddb354353558d3f1dc0691c58d51 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 6 Dec 2024 09:10:45 +0200 Subject: [PATCH 34/59] fixes for #53 --- .../ResourceActivationApiRouteBuilder.java | 28 ++--- ...sourceActivationApiRouteBuilderEvents.java | 112 ----------------- .../sim638/service/ServiceRepoService.java | 114 +++++++++--------- src/main/resources/application-testing.yml | 7 ++ src/main/resources/application.yml | 6 + 5 files changed, 83 insertions(+), 184 deletions(-) delete mode 100644 src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilderEvents.java 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 index dd7dab5..75c44d9 100644 --- a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilder.java @@ -46,17 +46,17 @@ public class ResourceActivationApiRouteBuilder extends RouteBuilder { private static final transient Log logger = LogFactory.getLog(ResourceActivationApiRouteBuilder.class.getName()); - @Value("${CATALOG_ADD_RESOURCE}") - private String CATALOG_ADD_RESOURCE = ""; + @Value("${CATALOG_ADD_RESOURCEACTIVATION}") + private String CATALOG_ADD_RESOURCEACTIVATION = ""; - @Value("${CATALOG_UPD_RESOURCE}") - private String CATALOG_UPD_RESOURCE = ""; + @Value("${CATALOG_UPD_RESOURCEACTIVATION}") + private String CATALOG_UPD_RESOURCEACTIVATION = ""; - @Value("${CATALOG_UPDADD_RESOURCE}") - private String CATALOG_UPDADD_RESOURCE = ""; + @Value("${CATALOG_UPDADD_RESOURCEACTIVATION}") + private String CATALOG_UPDADD_RESOURCEACTIVATION = ""; - @Value("${CATALOG_GET_RESOURCE_BY_ID}") - private String CATALOG_GET_RESOURCE_BY_ID = ""; + @Value("${CATALOG_GET_RESOURCEACTIVATION_BY_ID}") + private String CATALOG_GET_RESOURCEACTIVATION_BY_ID = ""; @Autowired private ProducerTemplate template; @@ -67,8 +67,8 @@ public class ResourceActivationApiRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { - from( CATALOG_ADD_RESOURCE ) - .log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " message received!") + 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})") @@ -76,16 +76,16 @@ public class ResourceActivationApiRouteBuilder extends RouteBuilder { .json( JsonLibrary.Jackson) .convertBodyTo( String.class ); - from( CATALOG_UPD_RESOURCE ) - .log(LoggingLevel.INFO, log, CATALOG_UPD_RESOURCE + " message received!") + 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_RESOURCE ) - .log(LoggingLevel.INFO, log, CATALOG_UPDADD_RESOURCE + " message received!") + 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})") diff --git a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilderEvents.java deleted file mode 100644 index c30136f..0000000 --- a/src/main/java/org/etsi/osl/tmf/ram702/api/ResourceActivationApiRouteBuilderEvents.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ========================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.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.tmf.common.model.Notification; -import org.etsi.osl.tmf.ri639.model.ResourceAttributeValueChangeNotification; -import org.etsi.osl.tmf.ri639.model.ResourceCreateNotification; -import org.etsi.osl.tmf.ri639.model.ResourceStateChangeNotification; - -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 ResourceActivationApiRouteBuilderEvents extends RouteBuilder { - - private static final transient Log logger = - LogFactory.getLog(ResourceActivationApiRouteBuilderEvents.class.getName()); - - - - @Value("${EVENT_RESOURCE_CREATE}") - private String EVENT_RESOURCE_CREATE = ""; - - @Value("${EVENT_RESOURCE_STATE_CHANGED}") - private String EVENT_RESOURCE_STATE_CHANGED = ""; - - @Value("${EVENT_RESOURCE_DELETE}") - private String EVENT_RESOURCE_DELETE = ""; - - @Value("${EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED}") - private String EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED = ""; - - - @Autowired - private ProducerTemplate template; - - - @Override - public void configure() throws Exception { - - } - - - /** - * @param n - */ - public void publishEvent(final Notification n, final String objId) { - n.setEventType(n.getClass().getName()); - logger.info("will send Event topic for type " + n.getEventType()); - try { - String msgtopic = ""; - - if (n instanceof ResourceCreateNotification) { - msgtopic = EVENT_RESOURCE_CREATE; - } else if (n instanceof ResourceAttributeValueChangeNotification) { - msgtopic = EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED; - }else if (n instanceof ResourceStateChangeNotification ) { - msgtopic = EVENT_RESOURCE_STATE_CHANGED; - } - - Map map = new HashMap<>(); - map.put("eventid", n.getEventId()); - map.put("objId", objId); - - template.sendBodyAndHeaders(msgtopic, toJsonString(n), map); - - } catch (Exception e) { - logger.error("Cannot send Event . " + e.getStackTrace()); - } - } - - 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/sim638/service/ServiceRepoService.java b/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java index 436cb6c..e037232 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 @@ -578,11 +578,15 @@ public class ServiceRepoService { } if (serviceCharacteristicChanged) { - Note noteItem = new Note(); - noteItem.setText("Service Characteristic changed: " + charChangedForNotes ); - noteItem.setAuthor("API"); - noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); - service.addNoteItem(noteItem); + + if (service.getServiceCharacteristicByName("_DETAILED_NOTES_") != null) { + Note noteItem = new Note(); + noteItem.setText("Service Characteristic changed: " + charChangedForNotes ); + noteItem.setAuthor("SIM638-API"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + service.addNoteItem(noteItem); + + } } @@ -1114,37 +1118,55 @@ public class ServiceRepoService { public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { - logger.info("Will update services related to this resource with id = " + res.getId() ); + 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 = findByUuid(as.getId()); + + List rlist = new ArrayList(); + for (ResourceRef rref : aService.getSupportingResource()) { + Optional 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); + String stateText=""; + if ( !aService.getState().equals(nextState)) { + stateText = "State changed from " + aService.getState() + " to " + nextState + "."; + } - //copy characteristics from resource to service + + //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 ); + Characteristic cNew = new Characteristic(); + cNew.setName( rChar.getName()); + cNew.value( new Any( rChar.getValue() )); + supd.addServiceCharacteristicItem( cNew ); } + if (as.getServiceCharacteristicByName("_DETAILED_NOTES_") != null) { + 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() ); + 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(), supd , true, null, null); //update the service - //} + this.updateService( aService.getId(), supd , true, null, null); //update the service + } @@ -1185,47 +1207,23 @@ public class ServiceRepoService { @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 rlist = new ArrayList(); - for (ResourceRef rref : aService.getSupportingResource()) { - Optional result = resourceRepo.findByUuid(rref.getId()); - if (result.isPresent()) { - rlist.add( result.get() ); - } - } + updateServicesHavingThisSupportingResource(res); - 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); } + /** + * 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) { diff --git a/src/main/resources/application-testing.yml b/src/main/resources/application-testing.yml index 719f8c5..20698fd 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -157,6 +157,13 @@ 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 163f1d3..a334391 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -189,6 +189,12 @@ 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" -- GitLab From 440f11a2665fbe4fe5dce962a15f378f1db0cdd1 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 6 Dec 2024 09:32:51 +0200 Subject: [PATCH 35/59] fix for tests --- .../osl/services/api/sim638/ServiceRepoServiceTest.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 4309b09..88db420 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 @@ -401,6 +401,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() ); -- GitLab From c45c19d872d0bc331c0590bb6418f37029b780a2 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 6 Dec 2024 10:10:11 +0200 Subject: [PATCH 36/59] fix for tests --- .../osl/services/api/ServiceInventoryIntegrationTest.java | 4 ++-- .../osl/services/api/sim638/ServiceRepoServiceTest.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) 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 16ad168..93e2554 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,7 +321,7 @@ 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" ) ; 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 88db420..8b9e706 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 @@ -258,7 +258,7 @@ public class ServiceRepoServiceTest { boolean expectedNoteExists = false; for (Note n : noteList) { - if ( n.getText().contains("State Changed with status:") && n.getAuthor().equals("SIM638-API")) { + if ( n.getText().contains("Supporting Resource changed with") && n.getAuthor().equals("SIM638-API")) { expectedNoteExists= true; break; } @@ -291,7 +291,7 @@ public class ServiceRepoServiceTest { Service updatedService = serviceRepoService.findByUuid(id); - assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 6 ); + assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 7 ); assertThat( updatedService.getSupportingResource().size() ).isEqualTo( 1); ResourceUpdate resourceUpdate = new ResourceUpdate(); @@ -313,14 +313,14 @@ public class ServiceRepoServiceTest { System.out.println("STEP 3 - =========================================== " ); updatedService = serviceRepoService.findByUuid(id); assertThat( updatedService.getSupportingResource().size() ).isEqualTo( 1); - assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 7 ); + assertThat( updatedService.getServiceCharacteristic().size() ).isEqualTo( 8 ); Set noteSet = updatedService.getNote(); List noteList = new ArrayList<>(noteSet); boolean expectedNoteExists = false; for (Note n : noteList) { - if ( n.getText().contains("Service Characteristic changed") && n.getAuthor().equals("API")) { + if ( n.getText().contains("Supporting Resource changed with") && n.getAuthor().equals("API")) { expectedNoteExists= true; break; } -- GitLab From 7a85806b2d476cb9ab072974be19329ea8faee4c Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 6 Dec 2024 10:20:55 +0200 Subject: [PATCH 37/59] fix for tests --- .../etsi/osl/services/api/sim638/ServiceRepoServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8b9e706..32238e9 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 @@ -320,7 +320,7 @@ public class ServiceRepoServiceTest { boolean expectedNoteExists = false; for (Note n : noteList) { - if ( n.getText().contains("Supporting Resource changed with") && n.getAuthor().equals("API")) { + if ( n.getText().contains("Supporting Resource changed with") && n.getAuthor().equals("SIM638-API")) { expectedNoteExists= true; break; } -- GitLab From 9850d827162448fa7b4ef3607eed939eb3ceb8b5 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 6 Dec 2024 12:17:38 +0200 Subject: [PATCH 38/59] fix for null --- .../reposervices/ServiceSpecificationRepoService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 f2a5172..eb6ca09 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 ); -- GitLab From 19e4611b545d31256e98967c56c70d3c265752df Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 6 Dec 2024 13:07:09 +0200 Subject: [PATCH 39/59] fixe for notes --- .../sim638/service/ServiceRepoService.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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 e037232..b69e14a 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 @@ -578,8 +578,12 @@ public class ServiceRepoService { } if (serviceCharacteristicChanged) { - - if (service.getServiceCharacteristicByName("_DETAILED_NOTES_") != null) { + + 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"); @@ -643,6 +647,11 @@ public class ServiceRepoService { this.addServiceActionQueueItem(saqi); } + + + + + /* * Update any parent service */ @@ -950,6 +959,8 @@ public class ServiceRepoService { public ServiceActionQueueItem addServiceActionQueueItem(@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 result = this.serviceActionQueueRepo.findByServiceRefIdAndAction(item.getServiceRefId(), item.getAction()); logger.debug("Will add ServiceActionQueueItem ServiceRefId result: " +result.size() ); @@ -1157,7 +1168,11 @@ public class ServiceRepoService { supd.addServiceCharacteristicItem( cNew ); } - if (as.getServiceCharacteristicByName("_DETAILED_NOTES_") != null) { + 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" ); -- GitLab From a2b39b6867f93b3b16663286eb581faedbb2485f Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 6 Dec 2024 16:30:23 +0200 Subject: [PATCH 40/59] fix for #55 --- .../sim638/service/ServiceRepoService.java | 84 +++++++++++++++---- .../api/sim638/ServiceRepoServiceTest.java | 5 +- 2 files changed, 71 insertions(+), 18 deletions(-) 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 b69e14a..d6ac3af 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,11 +24,14 @@ 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; @@ -350,6 +353,22 @@ public class ServiceRepoService { .orElse(null); } + /** + * @param id + * @param servUpd + * @param triggerServiceActionQueue + * @param updatedFromParentService + * @param updatedFromChildService + * @return + */ + /** + * @param id + * @param servUpd + * @param triggerServiceActionQueue + * @param updatedFromParentService + * @param updatedFromChildService + * @return + */ /** * @param id * @param servUpd @@ -572,6 +591,28 @@ public class ServiceRepoService { } + /** + * 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 + Set setB = new HashSet<>(Arrays.asList(arrayB)); + // Check if any value from stra exists in strb + boolean valueExists = false; + for (String value : arrayA) { + if (setB.contains(value)) { + valueExists = true; // A common value exists + } + } + if (!valueExists) { + serviceCharacteristicChanged=false; + } + } if (charChangedForNotes.contains( "reconciledAt") ) { //this is just a sync message, so we need to igore such changes serviceCharacteristicChanged = false; @@ -597,7 +638,13 @@ public class ServiceRepoService { service = this.serviceRepo.save( service ); - + String requestedServiceAsJson = null; + try { + requestedServiceAsJson = mapper.writeValueAsString( service ); + } catch (JsonProcessingException e) { + logger.error("cannot umarshall service: " + service.getName() ); + e.printStackTrace(); + } /** * Save in ServiceActionQueueItem @@ -617,7 +664,7 @@ public class ServiceRepoService { } if ( saqi.getAction() != ServiceActionQueueAction.NONE ) { - this.addServiceActionQueueItem(saqi); + this.addServiceActionQueueItem(service, saqi); } } @@ -626,13 +673,13 @@ public class ServiceRepoService { if ( stateChanged ) { ServiceActionQueueItem saqi = new ServiceActionQueueItem(); saqi.setServiceRefId( id ); - saqi.setOriginalServiceInJSON( originaServiceAsJson ); + saqi.setOriginalServiceInJSON( originaServiceAsJson ); if ( service.getState().equals( ServiceStateType.ACTIVE) ) { saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOACTIVE ); - this.addServiceActionQueueItem(saqi); + this.addServiceActionQueueItem(service, saqi); }else if ( previousState!=null && previousState.equals( ServiceStateType.ACTIVE) ) { saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ); - this.addServiceActionQueueItem(saqi); + this.addServiceActionQueueItem(service, saqi); } } @@ -644,7 +691,7 @@ public class ServiceRepoService { if ( serviceCharacteristicChangedContainsPrimitive ) { saqi.setAction( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED_MANODAY2 ); } - this.addServiceActionQueueItem(saqi); + this.addServiceActionQueueItem(service, saqi); } @@ -665,12 +712,12 @@ public class ServiceRepoService { 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 + 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); + this.addServiceActionQueueItem(service, saqi); } } @@ -685,7 +732,7 @@ public class ServiceRepoService { e.printStackTrace(); } saqi.setAction(ServiceActionQueueAction.EVALUATE_CHILD_STATE_CHANGE ); - this.addServiceActionQueueItem(saqi); + this.addServiceActionQueueItem(service, saqi); } } @@ -956,17 +1003,20 @@ public class ServiceRepoService { return (List) 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() ); + 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 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); - - //find any similar action inqueue and delete them, so to keep this one as the most recent - List 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); } /** 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 32238e9..c647b10 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 @@ -127,7 +127,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); -- GitLab From 14a73d7a8b1a2ef6209c34da123d1b8df0ff3d5a Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 18 Dec 2024 09:54:08 +0200 Subject: [PATCH 41/59] fix for #59 --- .../sim638/service/ServiceRepoService.java | 295 ++++++++++-------- .../api/ServiceInventoryIntegrationTest.java | 2 +- .../api/ServiceOrderIntegrationTest.java | 1 + .../api/sim638/ServiceRepoServiceTest.java | 47 +++ 4 files changed, 210 insertions(+), 135 deletions(-) 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 d6ac3af..2202dcf 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 @@ -286,6 +286,7 @@ public class ServiceRepoService { } + @Transactional public Service addService(@Valid ServiceCreate service) { logger.info("Will add service: " + service.getName() ); Service s = new Service(); @@ -335,11 +336,12 @@ 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.save( s ); raiseServiceCreateNotification(s); return s; @@ -353,22 +355,7 @@ public class ServiceRepoService { .orElse(null); } - /** - * @param id - * @param servUpd - * @param triggerServiceActionQueue - * @param updatedFromParentService - * @param updatedFromChildService - * @return - */ - /** - * @param id - * @param servUpd - * @param triggerServiceActionQueue - * @param updatedFromParentService - * @param updatedFromChildService - * @return - */ + /** * @param id * @param servUpd @@ -379,6 +366,9 @@ public class ServiceRepoService { */ @Transactional public Service updateService(String id, @Valid ServiceUpdate servUpd, boolean triggerServiceActionQueue, Service updatedFromParentService, Service updatedFromChildService ) { + + + logger.debug("================> Will updateService = " + id ); //Service service = this.findByUuid(id); Service service = this.getServiceEager(id); @@ -387,7 +377,10 @@ public class ServiceRepoService { 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() ); @@ -400,7 +393,8 @@ public class ServiceRepoService { e.printStackTrace(); } - + + if (servUpd.getType()!=null) { service.setType(servUpd.getType()); } @@ -541,6 +535,8 @@ public class ServiceRepoService { } else { service.addServiceCharacteristicItem(n); + + if ( !n.getName().contains("::") ) { //it is not a child characteristic serviceCharacteristicChanged = true; charChangedForNotes += n.getName() + ", "; @@ -585,9 +581,10 @@ 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); + logger.debug("=============SERVICE STATE ================================> " + service.getState() ); } @@ -633,11 +630,11 @@ public class ServiceRepoService { } } - - + service = this.serviceRepo.save( service ); + String requestedServiceAsJson = null; try { requestedServiceAsJson = mapper.writeValueAsString( service ); @@ -650,40 +647,28 @@ public class ServiceRepoService { * 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(service, 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(service, saqi); - }else if ( previousState!=null && previousState.equals( ServiceStateType.ACTIVE) ) { - saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ); - this.addServiceActionQueueItem(service, 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 ); @@ -691,7 +676,9 @@ public class ServiceRepoService { if ( serviceCharacteristicChangedContainsPrimitive ) { saqi.setAction( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED_MANODAY2 ); } + logger.debug("==========addServiceActionQueueItem==============> serviceCharacteristicChanged && service.getState().eq charChangedForNotes= " + charChangedForNotes); this.addServiceActionQueueItem(service, saqi); + childServiceCharacteristicChanged = true; } @@ -703,26 +690,10 @@ public class ServiceRepoService { * 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(service, 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()); @@ -731,13 +702,16 @@ public class ServiceRepoService { } catch (JsonProcessingException e) { e.printStackTrace(); } - saqi.setAction(ServiceActionQueueAction.EVALUATE_CHILD_STATE_CHANGE ); + 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); } } - - - } } } @@ -804,8 +778,7 @@ public class ServiceRepoService { // } catch (FileNotFoundException e) { // // TODO Auto-generated catch block // e.printStackTrace(); -// } - logger.info("======================================================================================================"); +// } } return service; @@ -921,10 +894,10 @@ public class ServiceRepoService { if ( schart!= null ) { String teest = schart.getValue().getValue(); - logger.info("schart size = " + teest.length() ); + logger.debug("schart size = " + teest.length() ); - logger.info("schart " + teest ); - logger.info("======================================================================================================"); + logger.debug("schart " + teest ); + logger.debug("======================================================================================================"); } return res; @@ -1011,6 +984,9 @@ public class ServiceRepoService { //find any similar action inqueue and delete them, so to keep this one as the most recent List 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()); } @@ -1179,16 +1155,14 @@ public class ServiceRepoService { public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { - logger.debug("Will update services related to this resource with id = " + res.getId() ); - + 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()); - + Service aService = getServiceEager(as.getId()); + + ServiceStateType nextState = aService.getState(); List rlist = new ArrayList(); for (ResourceRef rref : aService.getSupportingResource()) { Optional result = resourceRepo.findByUuid(rref.getId()); @@ -1196,41 +1170,101 @@ public class ServiceRepoService { rlist.add( result.get() ); } } - - rlist.add(res); //add also this one - ServiceStateType nextState = aService.findNextStateBasedOnSupportingResources(rlist); - - ServiceUpdate supd = new ServiceUpdate(); - supd.setState(nextState); - String stateText=""; - if ( !aService.getState().equals(nextState)) { - stateText = "State changed from " + aService.getState() + " to " + nextState + "."; + //copy characteristics, from resource to service + + /* + * Construct characteristic name + */ + 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); + 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 + "."; + } + + + + ServiceUpdate supd = new ServiceUpdate(); + nextState = aService.findNextStateBasedOnResourceList(rlist); + supd.setState(nextState); + String stateText=""; + if ( !aService.getState().equals(nextState)) { + stateText = "State changed from " + aService.getState() + " to " + nextState + "."; + logger.debug("====================> stateText = " + stateText); + for (Resource r : rlist) { + logger.debug("==================> s:"+ r.getResourceStatus().name()+ ", name:"+ r.getName() ); + } - - - //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 ); + } + + //adding all characteristics from service + for (Characteristic ch : aService.getServiceCharacteristic()) { + supd.addServiceCharacteristicItem(ch); + } + + + String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; + String[] arrayDontCopyChars = dontCopyChars.split(","); + Set 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(); + if ( supd.getServiceCharacteristicByName( characteristicname ) != null ) { + supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() )); + } else { + Characteristic cNew = new Characteristic(); + cNew.setName( characteristicname ); + cNew.value( new Any( rChar.getValue() )); + supd.addServiceCharacteristicItem( cNew ); + + } + + + } } + + } + - 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() ); - supd.addNoteItem( n ); - } - - this.updateService( aService.getId(), supd , true, null, null); //update the service + 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() ); + supd.addNoteItem( n ); + } + + this.updateService( aService.getId(), supd , true, null, null); //update the service } @@ -1242,6 +1276,8 @@ public class ServiceRepoService { } + + @Transactional public void resourceCreatedEvent(@Valid ResourceCreateNotification resNotif) { try { @@ -1271,12 +1307,10 @@ public class ServiceRepoService { @Transactional private void updateServiceFromresourceChange(Resource res) { - + + addAnyNewRelatedResourcesFromKubernetesLabel(res); updateServicesHavingThisSupportingResource(res); - - addAnyNewRelatedResourcesFromKubernetesLabel(res); - - + } /** @@ -1297,7 +1331,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; @@ -1316,14 +1350,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" ); 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 93e2554..68579fa 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java @@ -327,7 +327,7 @@ public class ServiceInventoryIntegrationTest { 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 b05c6e7..daeb2ed 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java @@ -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/sim638/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java index c647b10..0124945 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 @@ -296,11 +296,20 @@ public class ServiceRepoServiceTest { 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.setName( "newChar" ); resCharacteristicItem.setValue( new Any("myval0")); resourceUpdate.addResourceCharacteristicItem(resCharacteristicItem); @@ -458,6 +467,44 @@ public class ServiceRepoServiceTest { return response; } + @Test + public void testFindNextStateBasedOnSupportingResources() throws Exception { + Service s = new Service(); + s.setState(ServiceStateType.RESERVED); + List rlist = new ArrayList(); + 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") -- GitLab From 08be501fb3a06181666f56ec2a957e2ad082d0ae Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 18 Dec 2024 10:00:03 +0200 Subject: [PATCH 42/59] fix for #59 --- .../sim638/service/ServiceRepoService.java | 153 ++++++------------ 1 file changed, 51 insertions(+), 102 deletions(-) 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 2202dcf..9e7bb03 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 @@ -1155,14 +1155,16 @@ public class ServiceRepoService { public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { - logger.debug("================> Will update services related to this resource with id = " + res.getId() ); + 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 = getServiceEager(as.getId()); - - ServiceStateType nextState = aService.getState(); + Service aService = findByUuid(as.getId()); + List rlist = new ArrayList(); for (ResourceRef rref : aService.getSupportingResource()) { Optional result = resourceRepo.findByUuid(rref.getId()); @@ -1170,101 +1172,41 @@ public class ServiceRepoService { rlist.add( result.get() ); } } + + rlist.add(res); //add also this one - //copy characteristics, from resource to service - - /* - * Construct characteristic name - */ - 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); - 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 + "."; - } - - - - ServiceUpdate supd = new ServiceUpdate(); - nextState = aService.findNextStateBasedOnResourceList(rlist); - supd.setState(nextState); - String stateText=""; - if ( !aService.getState().equals(nextState)) { - stateText = "State changed from " + aService.getState() + " to " + nextState + "."; - logger.debug("====================> stateText = " + stateText); - for (Resource r : rlist) { - logger.debug("==================> s:"+ r.getResourceStatus().name()+ ", name:"+ r.getName() ); - + ServiceStateType nextState = aService.findNextStateBasedOnSupportingResources(rlist); + + ServiceUpdate supd = new ServiceUpdate(); + supd.setState(nextState); + String stateText=""; + if ( !aService.getState().equals(nextState)) { + stateText = "State changed from " + aService.getState() + " to " + nextState + "."; } - } - - //adding all characteristics from service - for (Characteristic ch : aService.getServiceCharacteristic()) { - supd.addServiceCharacteristicItem(ch); - } - - - String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; - String[] arrayDontCopyChars = dontCopyChars.split(","); - Set 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(); - if ( supd.getServiceCharacteristicByName( characteristicname ) != null ) { - supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() )); - } else { - Characteristic cNew = new Characteristic(); - cNew.setName( characteristicname ); - cNew.value( new Any( rChar.getValue() )); - supd.addServiceCharacteristicItem( cNew ); - - } - - - } + + + //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 ); } - - } - - 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() ); - supd.addNoteItem( n ); - } - - this.updateService( aService.getId(), supd , true, null, null); //update the service + 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() ); + supd.addNoteItem( n ); + } + + this.updateService( aService.getId(), supd , true, null, null); //update the service } @@ -1276,8 +1218,6 @@ public class ServiceRepoService { } - - @Transactional public void resourceCreatedEvent(@Valid ResourceCreateNotification resNotif) { try { @@ -1307,10 +1247,12 @@ public class ServiceRepoService { @Transactional private void updateServiceFromresourceChange(Resource res) { - - addAnyNewRelatedResourcesFromKubernetesLabel(res); + updateServicesHavingThisSupportingResource(res); - + + addAnyNewRelatedResourcesFromKubernetesLabel(res); + + } /** @@ -1331,7 +1273,7 @@ public class ServiceRepoService { String serviceId = res.getResourceCharacteristicByName("org.etsi.osl.serviceId").getValue().getValue(); logger.debug("rserviceId: " + serviceId); - Service aService = getServiceEager( serviceId ); + Service aService = findByUuid( serviceId ); if ( aService !=null ) { logger.debug("aService found "); Boolean resourceFoundInSupportedResourcesOfService = false; @@ -1350,7 +1292,14 @@ 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" ); -- GitLab From e31e84996b8909d08b6455bf4e8f69e37a1f17fe Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 18 Dec 2024 10:02:22 +0200 Subject: [PATCH 43/59] fix for #60 --- .../sim638/service/ServiceRepoService.java | 153 ++++++++++++------ 1 file changed, 102 insertions(+), 51 deletions(-) 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 9e7bb03..2202dcf 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 @@ -1155,16 +1155,14 @@ public class ServiceRepoService { public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { - logger.debug("Will update services related to this resource with id = " + res.getId() ); - + 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()); - + Service aService = getServiceEager(as.getId()); + + ServiceStateType nextState = aService.getState(); List rlist = new ArrayList(); for (ResourceRef rref : aService.getSupportingResource()) { Optional result = resourceRepo.findByUuid(rref.getId()); @@ -1172,41 +1170,101 @@ public class ServiceRepoService { rlist.add( result.get() ); } } - - rlist.add(res); //add also this one - ServiceStateType nextState = aService.findNextStateBasedOnSupportingResources(rlist); - - ServiceUpdate supd = new ServiceUpdate(); - supd.setState(nextState); - String stateText=""; - if ( !aService.getState().equals(nextState)) { - stateText = "State changed from " + aService.getState() + " to " + nextState + "."; + //copy characteristics, from resource to service + + /* + * Construct characteristic name + */ + 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); + 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 + "."; + } + + + + ServiceUpdate supd = new ServiceUpdate(); + nextState = aService.findNextStateBasedOnResourceList(rlist); + supd.setState(nextState); + String stateText=""; + if ( !aService.getState().equals(nextState)) { + stateText = "State changed from " + aService.getState() + " to " + nextState + "."; + logger.debug("====================> stateText = " + stateText); + for (Resource r : rlist) { + logger.debug("==================> s:"+ r.getResourceStatus().name()+ ", name:"+ r.getName() ); + } - - - //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 ); + } + + //adding all characteristics from service + for (Characteristic ch : aService.getServiceCharacteristic()) { + supd.addServiceCharacteristicItem(ch); + } + + + String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; + String[] arrayDontCopyChars = dontCopyChars.split(","); + Set 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(); + if ( supd.getServiceCharacteristicByName( characteristicname ) != null ) { + supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() )); + } else { + Characteristic cNew = new Characteristic(); + cNew.setName( characteristicname ); + cNew.value( new Any( rChar.getValue() )); + supd.addServiceCharacteristicItem( cNew ); + + } + + + } } + + } + - 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() ); - supd.addNoteItem( n ); - } - - this.updateService( aService.getId(), supd , true, null, null); //update the service + 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() ); + supd.addNoteItem( n ); + } + + this.updateService( aService.getId(), supd , true, null, null); //update the service } @@ -1218,6 +1276,8 @@ public class ServiceRepoService { } + + @Transactional public void resourceCreatedEvent(@Valid ResourceCreateNotification resNotif) { try { @@ -1247,12 +1307,10 @@ public class ServiceRepoService { @Transactional private void updateServiceFromresourceChange(Resource res) { - + + addAnyNewRelatedResourcesFromKubernetesLabel(res); updateServicesHavingThisSupportingResource(res); - - addAnyNewRelatedResourcesFromKubernetesLabel(res); - - + } /** @@ -1273,7 +1331,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; @@ -1292,14 +1350,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" ); -- GitLab From 09544bf4785e05eac71f6fc898cda7813080e432 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 18 Dec 2024 14:48:36 +0200 Subject: [PATCH 44/59] fix for #60 --- .../ri639/api/ResourceApiRouteBuilder.java | 10 +- .../sim638/api/ServiceApiRouteBuilder.java | 24 +-- .../sim638/service/ServiceRepoService.java | 144 ++++++++++++++---- 3 files changed, 134 insertions(+), 44 deletions(-) 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 fc6252f..bc445f1 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/sim638/api/ServiceApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java index b1e6877..84645c5 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})"); 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 2202dcf..1f17c69 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 @@ -341,7 +341,24 @@ public class ServiceRepoService { s.addNoteItem(noteItem); - s = this.serviceRepo.save( s ); + int cnt = 0; + if ( service.getServiceCharacteristic()!=null) + for (Characteristic ch : service.getServiceCharacteristic()) { + if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { + cnt++; + } + if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { + logger.debug("=============================================> FOUND CHARACTERISTIC addService AdditionPropertiesAsJson IN addService" ); + logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); + } + } + + if ( cnt>1) { + logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service addService" ); + + } + + s = this.serviceRepo.save( s ); raiseServiceCreateNotification(s); return s; @@ -394,7 +411,41 @@ public class ServiceRepoService { } - + int cnt = 0; + if ( servUpd.getServiceCharacteristic() != null ) { + for (Characteristic ch1 : servUpd.getServiceCharacteristic()) { + if ( ch1.getName().equals( "org.etsi.osl.prefixName" ) ) { + cnt++; + } + if ( ch1.getName().equals( "AdditionPropertiesAsJson" ) ) { + logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN servUpd" ); + logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch1.getValue().getValue().length() ); + } + + } + + if ( cnt>1) { + logger.debug("=============================================> FOUND CHARACTERISTIC TWICE servUpd updateService servUpd" ); + + } + } + cnt = 0; + for (Characteristic ch : service.getServiceCharacteristic()) { + if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { + cnt++; + } + if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { + logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN service" ); + logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); + } + } + + if ( cnt>1) { + logger.debug("=============================================> FOUND CHARACTERISTIC TWICE service updateService service" ); + + } + + if (servUpd.getType()!=null) { service.setType(servUpd.getType()); } @@ -536,7 +587,16 @@ public class ServiceRepoService { } else { service.addServiceCharacteristicItem(n); - + if ( n.getName().equals( "AdditionPropertiesAsJson" ) ) { + logger.debug("=============================================> ADDING AdditionPropertiesAsJson to service" ); + if ( n.getValue()!=null ) { + logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=" + n.getValue().getValue().length() ); + } else { + + logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=NULL" ); + } + + } if ( !n.getName().contains("::") ) { //it is not a child characteristic serviceCharacteristicChanged = true; charChangedForNotes += n.getName() + ", "; @@ -613,6 +673,7 @@ public class ServiceRepoService { 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) { @@ -634,7 +695,22 @@ public class ServiceRepoService { service = this.serviceRepo.save( service ); - + cnt = 0; + for (Characteristic ch : service.getServiceCharacteristic()) { + if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { + cnt++; + } + if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { + logger.debug("=============================================> FOUND CHARACTERISTIC AFTER AdditionPropertiesAsJson IN service" ); + logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); + } + } + + if ( cnt>1) { + logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service updateService service" ); + + } + String requestedServiceAsJson = null; try { requestedServiceAsJson = mapper.writeValueAsString( service ); @@ -778,7 +854,8 @@ public class ServiceRepoService { // } catch (FileNotFoundException e) { // // TODO Auto-generated catch block // e.printStackTrace(); -// } +// } + logger.info("======================================================================================================"); } return service; @@ -894,10 +971,10 @@ public class ServiceRepoService { if ( schart!= null ) { String teest = schart.getValue().getValue(); - logger.debug("schart size = " + teest.length() ); + logger.info("schart size = " + teest.length() ); - logger.debug("schart " + teest ); - logger.debug("======================================================================================================"); + logger.info("schart " + teest ); + logger.info("======================================================================================================"); } return res; @@ -1207,16 +1284,17 @@ public class ServiceRepoService { } - + 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("==================> s:"+ r.getResourceStatus().name()+ ", name:"+ r.getName() ); + logger.debug("==================> r:{}, state:{} ="+ r.getName() + ", "+ r.getResourceStatus().name()); } } @@ -1224,9 +1302,11 @@ public class ServiceRepoService { //adding all characteristics from service for (Characteristic ch : aService.getServiceCharacteristic()) { supd.addServiceCharacteristicItem(ch); + + } - + Boolean characteristicFoundDifferent =false; String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; String[] arrayDontCopyChars = dontCopyChars.split(","); Set setB = new HashSet<>(Arrays.asList(arrayDontCopyChars)); @@ -1235,14 +1315,21 @@ public class ServiceRepoService { if ( rChar.getValue() != null ) { String characteristicname = kind + resourcename + rChar.getName(); - if ( supd.getServiceCharacteristicByName( characteristicname ) != null ) { - supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() )); + 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("====================> add 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()); } @@ -1252,19 +1339,22 @@ public class ServiceRepoService { } - 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() ); - supd.addNoteItem( n ); - } - - this.updateService( aService.getId(), supd , true, null, null); //update the service + if ( stateChaged || 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() ); + supd.addNoteItem( n ); + } + + this.updateService( aService.getId(), supd , true, null, null); //update the service + + } } -- GitLab From 80d9cb4e3fb226056b48301ce0e202977b0330ec Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Thu, 19 Dec 2024 00:26:05 +0200 Subject: [PATCH 45/59] fix for #60. Ignoring prefix chars for services with no Kind --- .../org/etsi/osl/tmf/sim638/service/ServiceRepoService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1f17c69..44ff8c1 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 @@ -1266,7 +1266,7 @@ public class ServiceRepoService { resourcename = firstToken ; //example "cr0fc1234-amf" } - Boolean resourceIsSameKind = aService.checkIsKindResource(res); + 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=""; -- GitLab From 55ce2ecf2573240f0b7660442d92dbbdd630cf15 Mon Sep 17 00:00:00 2001 From: trantzas Date: Thu, 19 Dec 2024 10:33:36 +0000 Subject: [PATCH 46/59] code housekeeping --- .../sim638/service/ServiceRepoService.java | 179 +++++++++--------- 1 file changed, 86 insertions(+), 93 deletions(-) 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 44ff8c1..b439bc9 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 @@ -340,23 +340,25 @@ public class ServiceRepoService { noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); s.addNoteItem(noteItem); - - int cnt = 0; - if ( service.getServiceCharacteristic()!=null) - for (Characteristic ch : service.getServiceCharacteristic()) { - if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { - cnt++; - } - if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { - logger.debug("=============================================> FOUND CHARACTERISTIC addService AdditionPropertiesAsJson IN addService" ); - logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); - } - } - - if ( cnt>1) { - logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service addService" ); + // double characteristic investigation + // + // + // int cnt = 0; + // if ( service.getServiceCharacteristic()!=null) + // for (Characteristic ch : service.getServiceCharacteristic()) { + // if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { + // cnt++; + // } + // if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { + // logger.debug("=============================================> FOUND CHARACTERISTIC addService AdditionPropertiesAsJson IN addService" ); + // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); + // } + // } + + // if ( cnt>1) { + // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service addService" ); - } + // } s = this.serviceRepo.save( s ); @@ -410,40 +412,42 @@ public class ServiceRepoService { e.printStackTrace(); } - - int cnt = 0; - if ( servUpd.getServiceCharacteristic() != null ) { - for (Characteristic ch1 : servUpd.getServiceCharacteristic()) { - if ( ch1.getName().equals( "org.etsi.osl.prefixName" ) ) { - cnt++; - } - if ( ch1.getName().equals( "AdditionPropertiesAsJson" ) ) { - logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN servUpd" ); - logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch1.getValue().getValue().length() ); - } + // double characteristic investigation + // + // + // int cnt = 0; + // if ( servUpd.getServiceCharacteristic() != null ) { + // for (Characteristic ch1 : servUpd.getServiceCharacteristic()) { + // if ( ch1.getName().equals( "org.etsi.osl.prefixName" ) ) { + // cnt++; + // } + // if ( ch1.getName().equals( "AdditionPropertiesAsJson" ) ) { + // logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN servUpd" ); + // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch1.getValue().getValue().length() ); + // } - } + // } - if ( cnt>1) { - logger.debug("=============================================> FOUND CHARACTERISTIC TWICE servUpd updateService servUpd" ); + // if ( cnt>1) { + // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE servUpd updateService servUpd" ); - } - } - cnt = 0; - for (Characteristic ch : service.getServiceCharacteristic()) { - if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { - cnt++; - } - if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { - logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN service" ); - logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); - } - } - - if ( cnt>1) { - logger.debug("=============================================> FOUND CHARACTERISTIC TWICE service updateService service" ); + // } + // } + // cnt = 0; + // for (Characteristic ch : service.getServiceCharacteristic()) { + // if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { + // cnt++; + // } + // if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { + // logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN service" ); + // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); + // } + // } + + // if ( cnt>1) { + // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE service updateService service" ); - } + // } if (servUpd.getType()!=null) { @@ -587,16 +591,19 @@ public class ServiceRepoService { } else { service.addServiceCharacteristicItem(n); - if ( n.getName().equals( "AdditionPropertiesAsJson" ) ) { - logger.debug("=============================================> ADDING AdditionPropertiesAsJson to service" ); - if ( n.getValue()!=null ) { - logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=" + n.getValue().getValue().length() ); - } else { - - logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=NULL" ); - } + // double characteristic investigation + // + // + // if ( n.getName().equals( "AdditionPropertiesAsJson" ) ) { + // logger.debug("=============================================> ADDING AdditionPropertiesAsJson to service" ); + // if ( n.getValue()!=null ) { + // logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=" + n.getValue().getValue().length() ); + // } else { + + // logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=NULL" ); + // } - } + // } if ( !n.getName().contains("::") ) { //it is not a child characteristic serviceCharacteristicChanged = true; charChangedForNotes += n.getName() + ", "; @@ -695,21 +702,24 @@ public class ServiceRepoService { service = this.serviceRepo.save( service ); - cnt = 0; - for (Characteristic ch : service.getServiceCharacteristic()) { - if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { - cnt++; - } - if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { - logger.debug("=============================================> FOUND CHARACTERISTIC AFTER AdditionPropertiesAsJson IN service" ); - logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); - } - } - - if ( cnt>1) { - logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service updateService service" ); + // double characteristic investigation + // + // + // cnt = 0; + // for (Characteristic ch : service.getServiceCharacteristic()) { + // if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { + // cnt++; + // } + // if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { + // logger.debug("=============================================> FOUND CHARACTERISTIC AFTER AdditionPropertiesAsJson IN service" ); + // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); + // } + // } + + // if ( cnt>1) { + // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service updateService service" ); - } + // } String requestedServiceAsJson = null; try { @@ -841,23 +851,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; } @@ -967,15 +960,15 @@ public class ServiceRepoService { String res = mapper.writeValueAsString(s); - Characteristic schart = s.getServiceCharacteristicByName("long_string"); + // Characteristic schart = s.getServiceCharacteristicByName("long_string"); - if ( schart!= null ) { - String teest = schart.getValue().getValue(); - logger.info("schart size = " + teest.length() ); + // if ( schart!= null ) { + // String teest = schart.getValue().getValue(); + // logger.debug("schart size = " + teest.length() ); - logger.info("schart " + teest ); - logger.info("======================================================================================================"); - } + // logger.debug("schart " + teest ); + // logger.debug("======================================================================================================"); + // } return res; } -- GitLab From edb211d4f9f2439f52ef266a6c91e934df4835e4 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Thu, 19 Dec 2024 15:01:21 +0200 Subject: [PATCH 47/59] fix for #60 --- .../org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java | 1 + 1 file changed, 1 insertion(+) 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 0124945..99e752a 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 @@ -247,6 +247,7 @@ public class ServiceRepoServiceTest { ResourceRef firstResourceRef = resourceRefList.get(0); Resource resource = resourceRepoService.findByUuid(firstResourceRef.getId()); + resource.setResourceStatus(ResourceStatusType.STANDBY); ResourceStateChangeNotification resourceCreateNotification = new ResourceStateChangeNotification(); ResourceStateChangeEvent event = new ResourceStateChangeEvent(); -- GitLab From c0cbfd01a2516c268bde5dfaefa37910e7066ca8 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 20 Dec 2024 11:42:17 +0200 Subject: [PATCH 48/59] fix for #61 --- .../reposervices/ResourceRepoService.java | 1 - .../sim638/api/ServiceApiRouteBuilder.java | 26 ++-- .../sim638/service/ServiceRepoService.java | 132 +++--------------- 3 files changed, 31 insertions(+), 128 deletions(-) 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 7f52235..e3f0f4c 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 @@ -449,7 +449,6 @@ public class ResourceRepoService { resource = this.resourceRepo.save(resource); - this.serviceRepoService.updateServicesHavingThisSupportingResource(resource); if (resourceCharacteristicChanged) { raiseResourceAttributeValueChangeEventNotification(resource); 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 84645c5..9373f79 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 @@ -224,19 +224,19 @@ public class ServiceApiRouteBuilder extends RouteBuilder { -// from( EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED ) -// .errorHandler(deadLetterChannel("direct:retriesDeadLetters") -// .maximumRedeliveries(5) -// .redeliveryDelay(1000).useOriginalMessage() -// .logExhausted(true) -// .logHandled(true) -// .retriesExhaustedLogLevel(LoggingLevel.ERROR) -// .retryAttemptedLogLevel(LoggingLevel.ERROR)) -// -// .log(LoggingLevel.INFO, 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})"); + from( EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED ) + .errorHandler(deadLetterChannel("direct:retriesDeadLetters") + .maximumRedeliveries(5) + .redeliveryDelay(1000).useOriginalMessage() + .logExhausted(true) + .logHandled(true) + .retriesExhaustedLogLevel(LoggingLevel.ERROR) + .retryAttemptedLogLevel(LoggingLevel.ERROR)) + + .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/service/ServiceRepoService.java b/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java index b439bc9..f28905b 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 @@ -340,26 +340,6 @@ public class ServiceRepoService { noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); s.addNoteItem(noteItem); - // double characteristic investigation - // - // - // int cnt = 0; - // if ( service.getServiceCharacteristic()!=null) - // for (Characteristic ch : service.getServiceCharacteristic()) { - // if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { - // cnt++; - // } - // if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { - // logger.debug("=============================================> FOUND CHARACTERISTIC addService AdditionPropertiesAsJson IN addService" ); - // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); - // } - // } - - // if ( cnt>1) { - // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service addService" ); - - // } - s = this.serviceRepo.save( s ); raiseServiceCreateNotification(s); @@ -385,23 +365,15 @@ public class ServiceRepoService { */ @Transactional public Service updateService(String id, @Valid ServiceUpdate servUpd, boolean triggerServiceActionQueue, Service updatedFromParentService, Service updatedFromChildService ) { - - logger.debug("================> Will updateService = " + id ); - //Service service = this.findByUuid(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; @@ -412,43 +384,6 @@ public class ServiceRepoService { e.printStackTrace(); } - // double characteristic investigation - // - // - // int cnt = 0; - // if ( servUpd.getServiceCharacteristic() != null ) { - // for (Characteristic ch1 : servUpd.getServiceCharacteristic()) { - // if ( ch1.getName().equals( "org.etsi.osl.prefixName" ) ) { - // cnt++; - // } - // if ( ch1.getName().equals( "AdditionPropertiesAsJson" ) ) { - // logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN servUpd" ); - // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch1.getValue().getValue().length() ); - // } - - // } - - // if ( cnt>1) { - // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE servUpd updateService servUpd" ); - - // } - // } - // cnt = 0; - // for (Characteristic ch : service.getServiceCharacteristic()) { - // if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { - // cnt++; - // } - // if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { - // logger.debug("=============================================> FOUND CHARACTERISTIC AdditionPropertiesAsJson IN service" ); - // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); - // } - // } - - // if ( cnt>1) { - // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE service updateService service" ); - - // } - if (servUpd.getType()!=null) { service.setType(servUpd.getType()); @@ -497,8 +432,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 ) { @@ -539,10 +478,6 @@ public class ServiceRepoService { boolean serviceCharacteristicChangedContainsNSLCM; String charChangedForNotes = ""; - //List childCharacteristicsChanged = new ArrayList<>(); - - - //logger.info("==> Will update serviceToString: " + service.toString() ); if ( servUpd.getServiceCharacteristic()!=null ) { @@ -590,20 +525,7 @@ public class ServiceRepoService { } else { service.addServiceCharacteristicItem(n); - - // double characteristic investigation - // - // - // if ( n.getName().equals( "AdditionPropertiesAsJson" ) ) { - // logger.debug("=============================================> ADDING AdditionPropertiesAsJson to service" ); - // if ( n.getValue()!=null ) { - // logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=" + n.getValue().getValue().length() ); - // } else { - - // logger.debug("=============================================> ADDING AdditionPropertiesAsJson charlength=NULL" ); - // } - - // } + if ( !n.getName().contains("::") ) { //it is not a child characteristic serviceCharacteristicChanged = true; charChangedForNotes += n.getName() + ", "; @@ -651,7 +573,6 @@ public class ServiceRepoService { noteItem.setAuthor("SIM-638"); noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); service.addNoteItem(noteItem); - logger.debug("=============SERVICE STATE ================================> " + service.getState() ); } @@ -702,24 +623,7 @@ public class ServiceRepoService { service = this.serviceRepo.save( service ); - // double characteristic investigation - // - // - // cnt = 0; - // for (Characteristic ch : service.getServiceCharacteristic()) { - // if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) { - // cnt++; - // } - // if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) { - // logger.debug("=============================================> FOUND CHARACTERISTIC AFTER AdditionPropertiesAsJson IN service" ); - // logger.debug("=============================================> AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() ); - // } - // } - - // if ( cnt>1) { - // logger.debug("=============================================> FOUND CHARACTERISTIC TWICE AFTER service updateService service" ); - - // } + String requestedServiceAsJson = null; try { @@ -958,17 +862,6 @@ 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.debug("schart size = " + teest.length() ); - - // logger.debug("schart " + teest ); - // logger.debug("======================================================================================================"); - // } return res; } @@ -1313,7 +1206,7 @@ public class ServiceRepoService { if (! servChar.getValue().getValue().equals( rChar.getValue().getValue() ) ) { characteristicFoundDifferent = true; supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() )); - logger.debug("====================> add characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue()); + logger.debug("====================> update characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue()); } } else { @@ -1385,7 +1278,18 @@ 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 -- GitLab From 8dbd61c2cccb502a56be846622d3628249507416 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 20 Dec 2024 12:03:56 +0200 Subject: [PATCH 49/59] fix for #61 --- .../services/api/sim638/ServiceRepoServiceTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 99e752a..243915a 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 @@ -287,11 +287,7 @@ public class ServiceRepoServiceTest { - @Valid ResourceAttributeValueChangeNotification resNotid = new ResourceAttributeValueChangeNotification(); - ResourceAttributeValueChangeEvent event = new ResourceAttributeValueChangeEvent(); - event.getEvent().setResource(resource); - - resNotid.setEvent( event ); + Service updatedService = serviceRepoService.findByUuid(id); @@ -324,10 +320,14 @@ public class ServiceRepoServiceTest { 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 noteSet = updatedService.getNote(); List noteList = new ArrayList<>(noteSet); -- GitLab From ba197b536ad27c95c5d27cabf67c0d238adda35e Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 21 Dec 2024 17:23:28 +0200 Subject: [PATCH 50/59] fix for #61 --- .../sim638/service/ServiceRepoService.java | 183 ++++++++++++------ .../reposervices/ServiceOrderRepoService.java | 13 +- 2 files changed, 124 insertions(+), 72 deletions(-) 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 f28905b..a8687f9 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 @@ -1118,8 +1118,14 @@ public class ServiceRepoService { public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { + 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) { @@ -1131,6 +1137,10 @@ public class ServiceRepoService { Optional 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; + } } } @@ -1139,35 +1149,9 @@ public class ServiceRepoService { /* * Construct characteristic name */ - 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 + "."; - } + Boolean stateChaged = false; @@ -1179,10 +1163,10 @@ public class ServiceRepoService { stateChaged = true; stateText = "State changed from " + aService.getState() + " to " + nextState + "."; logger.debug("====================> stateText = " + stateText); - for (Resource r : rlist) { - logger.debug("==================> r:{}, state:{} ="+ r.getName() + ", "+ r.getResourceStatus().name()); - - } + } + for (Resource r : rlist) { + logger.debug("==================> state: ="+ r.getResourceStatus().name() + ", "+ r.getName() ); + } //adding all characteristics from service @@ -1192,40 +1176,24 @@ public class ServiceRepoService { } - Boolean characteristicFoundDifferent =false; - String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; - String[] arrayDontCopyChars = dontCopyChars.split(","); - Set 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, false); + + if ( nextState == ServiceStateType.ACTIVE) { + if ( !aService.equals(nextState) && nextState == ServiceStateType.ACTIVE) { + result = copyCharacteristicsFromAllResources(aService, supd, rlist); + } else { + result = copyCharacteristicsFromResource(aService, supd, res); } - } + + + + + - if ( stateChaged || characteristicFoundDifferent) { + if ( stateChaged || result.characteristicFoundDifferent) { Characteristic noteCheck = as.getServiceCharacteristicByName("_DETAILED_NOTES_"); if ( noteCheck!= null && noteCheck.getValue() != null @@ -1235,10 +1203,10 @@ public class ServiceRepoService { n.setText(stateText + "Supporting Resource changed with id: " + res.getId()); n.setAuthor( "SIM638-API" ); n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); - supd.addNoteItem( n ); + result.supd.addNoteItem( n ); } - this.updateService( aService.getId(), supd , true, null, null); //update the service + this.updateService( aService.getId(), result.supd , true, null, null); //update the service } @@ -1251,9 +1219,96 @@ public class ServiceRepoService { } + private record CharCopyResult(ServiceUpdate supd, Boolean characteristicFoundDifferent) { + + } + private CharCopyResult copyCharacteristicsFromAllResources(Service aService, ServiceUpdate supd, List 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 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 { 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 c761b52..b790f19 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 @@ -914,15 +914,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; -- GitLab From 2f158643bf5b1e5d52562fc0ed39b5a5dd2cb6b3 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 21 Dec 2024 22:48:23 +0200 Subject: [PATCH 51/59] fix for #61 --- .../sim638/service/ServiceRepoService.java | 20 +++++++++++-------- .../reposervices/ServiceOrderRepoService.java | 15 ++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) 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 a8687f9..c8761b4 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 @@ -1133,14 +1133,18 @@ public class ServiceRepoService { ServiceStateType nextState = aService.getState(); List rlist = new ArrayList(); + rlist.add(res); + for (ResourceRef rref : aService.getSupportingResource()) { - Optional 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; - } + if (!rref.getId().equals( res.getId())) { + Optional 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; + } + } } } @@ -1180,7 +1184,7 @@ public class ServiceRepoService { CharCopyResult result = new CharCopyResult(supd, false); if ( nextState == ServiceStateType.ACTIVE) { - if ( !aService.equals(nextState) && nextState == ServiceStateType.ACTIVE) { + if ( !aService.getState().equals(nextState) && nextState == ServiceStateType.ACTIVE) { result = copyCharacteristicsFromAllResources(aService, supd, rlist); } else { result = copyCharacteristicsFromResource(aService, supd, res); 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 b790f19..64f6604 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 @@ -884,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; } -- GitLab From 76a337df3b5c0b7edab09331555d96ee22138ed5 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 21 Dec 2024 23:16:34 +0200 Subject: [PATCH 52/59] fix #61 for test --- .../etsi/osl/services/api/sim638/ServiceRepoServiceTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 243915a..9150fb1 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 @@ -307,6 +307,7 @@ public class ServiceRepoServiceTest { 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); @@ -315,7 +316,8 @@ public class ServiceRepoServiceTest { System.out.println("STEP 1 - =========================================== " +serviceRepoService.toString() ); Resource nullResource = resourceRepoService.updateResource( resource.getId(), resourceUpdate, false); resource = resourceRepoService.findByUuid(firstResourceRef.getId()); - assertThat( resource.getResourceCharacteristic().size() ).isEqualTo( 1 ); + nullResource.setResourceStatus(ResourceStatusType.AVAILABLE); + assertThat( resource.getResourceCharacteristic().size() ).isEqualTo( 2 ); Thread.sleep(1000); -- GitLab From 107142bd32b49adb05c8e960bb9a9dab43751d65 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 10 Jan 2025 12:38:43 +0200 Subject: [PATCH 53/59] fix for #62 --- .../pm628/reposervices/MeasurementCollectionJobService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 index 9aecf9e..af420a7 100755 --- a/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java @@ -289,9 +289,10 @@ public class MeasurementCollectionJobService { MeasurementCollectionJobMapper mapper = Mappers.getMapper(MeasurementCollectionJobMapper.class); MeasurementCollectionJob mcj = mapper.createMeasurementCollectionJob(measurementCollectionJobFVO); + mcj = this.measurementCollectionJobRepository.save(mcj); raiseMCJCreateNotification(mcj); - return this.measurementCollectionJobRepository.save(mcj); + return mcj; } public MeasurementCollectionJob updateMeasurementCollectionJob(String uuid, @Valid MeasurementCollectionJobMVO measurementCollectionJobUpdate){ @@ -306,7 +307,7 @@ public class MeasurementCollectionJobService { MeasurementCollectionJobMapper mapper = Mappers.getMapper(MeasurementCollectionJobMapper.class); measurementCollectionJob = mapper.updateMeasurementCollectionJob(measurementCollectionJobUpdate, measurementCollectionJob); - this.measurementCollectionJobRepository.save(measurementCollectionJob); + measurementCollectionJob = this.measurementCollectionJobRepository.save(measurementCollectionJob); // This may be unnecessary since MeasurementCollectionJobMVO doesn't have the executionState attribute executionStateChanged = !originalExecutionState.equals(measurementCollectionJob.getExecutionState()); -- GitLab From 9fe493a0d8ba5800d5985ced9d498f1efc4180bd Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 11 Jan 2025 02:24:30 +0200 Subject: [PATCH 54/59] fixes for metrico --- ...asurementCollectionJobApiRouteBuilder.java | 8 +-- .../MeasurementCollectionJobService.java | 49 ++++++++++++++++++- 2 files changed, 52 insertions(+), 5 deletions(-) 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 index 0e5e1c7..a56998c 100644 --- a/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java @@ -30,7 +30,7 @@ public class MeasurementCollectionJobApiRouteBuilder extends RouteBuilder { private String PM_GET_MEASUREMENT_COLLECTION_JOBS; @Value("${PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID}") - private String PM_GET_MEASUREMENT_COLLECTION_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; @@ -58,10 +58,10 @@ public class MeasurementCollectionJobApiRouteBuilder extends RouteBuilder { .bean(measurementCollectionJobService, "findAllMeasurementCollectionJobs") .convertBodyTo( String.class ); - from(PM_GET_MEASUREMENT_COLLECTION_JOB_BY_ID) - .log(LoggingLevel.INFO, log, PM_GET_MEASUREMENT_COLLECTION_JOB_BY_ID + " message received!") + 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, "findMeasurementCollectionJobByUuid") + .bean(measurementCollectionJobService, "findMeasurementCollectionJobByUuidEagerAsString") .convertBodyTo( String.class ); from(PM_ADD_MEASUREMENT_COLLECTION_JOB) 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 index af420a7..46960b7 100755 --- a/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java @@ -6,6 +6,7 @@ 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.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; @@ -20,6 +21,9 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; 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 @@ -277,6 +281,47 @@ public class MeasurementCollectionJobService { 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); + + return res; + + } + + + private MeasurementCollectionJob findMeasurementCollectionJobByUuidEager(String id) { + if ( id == null || id.equals("")) { + return null; + } + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + MeasurementCollectionJob s = null; + try { + s = (MeasurementCollectionJob) session.get(MeasurementCollectionJob.class, id); + if (s == null) { + 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(); + } finally { + session.close(); + } + + return s; + } + public MeasurementCollectionJob findMeasurementCollectionJobByUuid(String uuid){ log.debug("MeasurementCollectionJob FIND BY UUID"); Optional measurementCollectionJob = measurementCollectionJobRepository.findByUuid(uuid); @@ -310,7 +355,9 @@ public class MeasurementCollectionJobService { measurementCollectionJob = this.measurementCollectionJobRepository.save(measurementCollectionJob); // This may be unnecessary since MeasurementCollectionJobMVO doesn't have the executionState attribute - executionStateChanged = !originalExecutionState.equals(measurementCollectionJob.getExecutionState()); + if ( originalExecutionState!=null) { + executionStateChanged = !originalExecutionState.equals(measurementCollectionJob.getExecutionState()); + } if (executionStateChanged) { raiseMCJExecutionStateChangeNotification(measurementCollectionJob); -- GitLab From 983bb4fdc29b65c24735566029a474ec2bc0b7fb Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 11 Jan 2025 18:44:17 +0200 Subject: [PATCH 55/59] fixes for metrico events --- .../pm628/api/MeasurementCollectionJobApiRouteBuilder.java | 5 ++++- .../pm628/reposervices/MeasurementCollectionJobService.java | 2 ++ .../org/etsi/osl/tmf/sim638/service/ServiceRepoService.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) 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 index a56998c..b8fbcca 100644 --- a/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/api/MeasurementCollectionJobApiRouteBuilder.java @@ -66,9 +66,11 @@ public class MeasurementCollectionJobApiRouteBuilder extends RouteBuilder { 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() + .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) @@ -76,6 +78,7 @@ public class MeasurementCollectionJobApiRouteBuilder extends RouteBuilder { .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 ); } 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 index 46960b7..ada0cd1 100755 --- a/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java @@ -384,6 +384,8 @@ public class MeasurementCollectionJobService { MeasurementCollectionJobRef ref = new MeasurementCollectionJobRef(); ref.setId(mcj.getUuid()); ref.setHref(mcj.getHref()); + ref.setName("MeasurementCollectionJob"); + MeasurementCollectionJobCreateEventPayload payload = new MeasurementCollectionJobCreateEventPayload(); payload.setMeasurementCollectionJob(ref); 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 c8761b4..62d067a 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 @@ -866,7 +866,7 @@ public class ServiceRepoService { return res; } - @Transactional + public Service getServiceEager(String id) { if ( id == null || id.equals("")) { return null; -- GitLab From 72fc080d28fb3ce82356d4a0536918a732240db9 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sun, 12 Jan 2025 10:02:39 +0200 Subject: [PATCH 56/59] fixes for DB connection leaks for metrico transactions --- .../MeasurementCollectionJobRepository.java | 8 +-- .../MeasurementCollectionJobService.java | 57 ++++++++++++------- src/main/resources/application.yml | 11 ++-- ...urementCollectionJobApiControllerTest.java | 35 ++++++++++++ 4 files changed, 80 insertions(+), 31 deletions(-) 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 index 444e9d0..244016e 100644 --- a/src/main/java/org/etsi/osl/tmf/pm628/repo/MeasurementCollectionJobRepository.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/repo/MeasurementCollectionJobRepository.java @@ -1,15 +1,13 @@ 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.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.Optional; - @Repository -public interface MeasurementCollectionJobRepository extends CrudRepository, PagingAndSortingRepository { +public interface MeasurementCollectionJobRepository extends JpaRepository { Optional findByUuid(String uuid); Iterable findByExecutionState(ExecutionStateType executionState); 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 index ada0cd1..4ca0cea 100755 --- a/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java +++ b/src/main/java/org/etsi/osl/tmf/pm628/reposervices/MeasurementCollectionJobService.java @@ -6,6 +6,7 @@ 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; @@ -15,11 +16,13 @@ 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; @@ -288,58 +291,63 @@ public class MeasurementCollectionJobService { 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("")) { + if (id == null || id.equals("")) { return null; - } - Session session = sessionFactory.openSession(); - Transaction tx = session.beginTransaction(); - MeasurementCollectionJob s = null; - try { + } + MeasurementCollectionJob s = null; + try (Session session = sessionFactory.openSession()) { + Transaction tx = session.beginTransaction(); s = (MeasurementCollectionJob) session.get(MeasurementCollectionJob.class, id); if (s == null) { - return this.findMeasurementCollectionJobByUuid(id);// last resort + 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.getDataAccessEndpoint()); + Hibernate.initialize(s.getFileTransferData()); + Hibernate.initialize(s.getPerformanceIndicatorGroupSpecification()); Hibernate.initialize(s.getPerformanceIndicatorSpecification()); - Hibernate.initialize(s.getScheduleDefinition() ); - Hibernate.initialize(s.getTrackingRecord() ); - + Hibernate.initialize(s.getScheduleDefinition()); + Hibernate.initialize(s.getTrackingRecord()); + tx.commit(); - } finally { - session.close(); - } - - return s; + } catch (Exception e) { + e.printStackTrace(); + } + + return s; } + @Transactional public MeasurementCollectionJob findMeasurementCollectionJobByUuid(String uuid){ log.debug("MeasurementCollectionJob FIND BY UUID"); Optional 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 = this.measurementCollectionJobRepository.save(mcj); + 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); @@ -352,8 +360,10 @@ public class MeasurementCollectionJobService { 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()); @@ -373,12 +383,12 @@ public class MeasurementCollectionJobService { 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(); @@ -399,6 +409,7 @@ public class MeasurementCollectionJobService { routeBuilderEvents.publishEvent(event, mcj.getUuid()); } + @Transactional private void raiseMCJAttributeValueChangeNotification(MeasurementCollectionJob mcj){ // Create the event payload @@ -414,6 +425,7 @@ public class MeasurementCollectionJobService { routeBuilderEvents.publishEvent(event, mcj.getUuid()); } + @Transactional private void raiseMCJExecutionStateChangeNotification(MeasurementCollectionJob mcj){ // Create the event payload @@ -429,6 +441,7 @@ public class MeasurementCollectionJobService { routeBuilderEvents.publishEvent(event, mcj.getUuid()); } + @Transactional private void raiseMCJDeleteNotification(MeasurementCollectionJob mcj){ // Create the event payload diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 603a244..894408a 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: 30000 + + jpa: database-platform: org.etsi.osl.tmf.LocalMysqlDialect hibernate: 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 index 40a2697..a2d93c3 100644 --- a/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobApiControllerTest.java +++ b/src/test/java/org/etsi/osl/services/api/pm628/MeasurementCollectionJobApiControllerTest.java @@ -1,5 +1,6 @@ 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; @@ -114,6 +115,7 @@ public class MeasurementCollectionJobApiControllerTest { assertThat(mcj2.getReportingPeriod()).isEqualTo(mcj.getReportingPeriod()); } + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) @Test public void testCreateMeasurementCollectionJob() throws Exception { @@ -126,6 +128,39 @@ public class MeasurementCollectionJobApiControllerTest { 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 toJsonObj(String content, Class valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.readValue( content, valueType); } @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) -- GitLab From a50dd692231b5967528bc1a10c4594e1085ca5e5 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sun, 12 Jan 2025 13:19:38 +0200 Subject: [PATCH 57/59] fixes for addressing issue #63 --- .../tmf/ri639/repo/ResourceRepository.java | 5 +- .../reposervices/ResourceRepoService.java | 29 ++- .../tmf/sim638/repo/ServiceRepository.java | 5 +- .../sim638/service/ServiceRepoService.java | 24 +- .../so641/repo/ServiceOrderRepository.java | 5 +- .../reposervices/ServiceOrderRepoService.java | 22 +- src/main/resources/application.yml | 2 +- .../api/ResourceInventoryIntegrationTest.java | 222 ++++++++++++++++-- .../api/sim638/ServiceRepoServiceTest.java | 25 ++ .../ri639/ResourceRepoServiceTest.java | 5 +- 10 files changed, 274 insertions(+), 70 deletions(-) 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 86de40b..446a04c 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, PagingAndSortingRepository { +public interface ResourceRepository extends JpaRepository { Optional 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 e3f0f4c..3f645f4 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 @@ -67,6 +67,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 jakarta.persistence.EntityManagerFactory; import jakarta.validation.Valid; @@ -199,7 +200,7 @@ public class ResourceRepoService { return (List) this.resourceRepo.findByRolename(name); } - + @Transactional public Resource addResource(@Valid ResourceCreate resource) { logger.info("Will add Resource: " + resource.getName()); @@ -272,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; @@ -448,7 +449,7 @@ public class ResourceRepoService { } - resource = this.resourceRepo.save(resource); + resource = this.resourceRepo.saveAndFlush(resource); if (resourceCharacteristicChanged) { raiseResourceAttributeValueChangeEventNotification(resource); @@ -458,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(); @@ -467,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 @@ -487,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(); @@ -505,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(); @@ -516,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(); @@ -554,6 +558,7 @@ public class ResourceRepoService { return result; } + @Transactional public Void deleteByUuid(String id) { Optional optionalCat = this.resourceRepo.findByUuid(id); Resource s = optionalCat.get(); 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 bd2cbf0..8c92037 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, PagingAndSortingRepository { +public interface ServiceRepository extends JpaRepository { Optional 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 62d067a..01b5b31 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 @@ -78,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; @@ -340,7 +341,7 @@ public class ServiceRepoService { noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); s.addNoteItem(noteItem); - s = this.serviceRepo.save( s ); + s = this.serviceRepo.saveAndFlush( s ); raiseServiceCreateNotification(s); return s; @@ -621,7 +622,7 @@ public class ServiceRepoService { } - service = this.serviceRepo.save( service ); + service = this.serviceRepo.saveAndFlush( service ); @@ -867,14 +868,14 @@ public class ServiceRepoService { } + @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 @@ -891,15 +892,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(); @@ -909,7 +911,7 @@ public class ServiceRepoService { } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseServiceStateChangedNotification(Service so) { ServiceStateChangeNotification n = new ServiceStateChangeNotification(); ServiceStateChangeEvent event = new ServiceStateChangeEvent(); @@ -919,7 +921,7 @@ public class ServiceRepoService { } - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) private void raiseServiceAttributeValueChangedNotification(Service so) { ServiceAttributeValueChangeNotification n = new ServiceAttributeValueChangeNotification(); ServiceAttributeValueChangeEvent event = new ServiceAttributeValueChangeEvent(); 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 3279fad..c717e06 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, PagingAndSortingRepository { +public interface ServiceOrderRepository extends JpaRepository { Optional 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 64f6604..4c44519 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 @@ -59,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; @@ -365,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 ); @@ -376,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); @@ -658,13 +659,14 @@ public class ServiceOrderRepoService { - so = this.serviceOrderRepo.save(so); + so = this.serviceOrderRepo.saveAndFlush(so); if (stateChanged) { raiseSOStateChangedNotification(so); } else { raiseSOAttributeValueChangedNotification(so); } + return so; } @@ -737,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); @@ -770,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(); @@ -786,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(); @@ -797,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(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 894408a..3722fa8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -53,7 +53,7 @@ spring: idleTimeout: 20000 idle-timeout: 20000 connectionTimeout: 40000 - leakDetectionThreshold: 30000 + leakDetectionThreshold: 40000 jpa: 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 fd6989e..9e8f625 100644 --- a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java @@ -330,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/sim638/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java index 9150fb1..d433726 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 @@ -52,6 +52,11 @@ 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.*; @@ -103,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.] 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 index 8100820..84fe0e8 100644 --- a/src/test/java/org/etsi/osl/services/reposervices/ri639/ResourceRepoServiceTest.java +++ b/src/test/java/org/etsi/osl/services/reposervices/ri639/ResourceRepoServiceTest.java @@ -117,6 +117,7 @@ public class ResourceRepoServiceTest { 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()); } @@ -174,7 +175,7 @@ public class ResourceRepoServiceTest { // Then assertNotNull(result); assertEquals("test_resource", result.getName()); - verify(resourceRepo, times(1)).save(any(Resource.class)); + verify(resourceRepo, times(1)).saveAndFlush(any(Resource.class)); } /** @@ -210,7 +211,7 @@ public class ResourceRepoServiceTest { assertEquals(ResourceStatusType.AVAILABLE, updatedResource.getResourceStatus()); assertEquals("2.0", updatedResource.getResourceVersion()); - verify(resourceRepo, times(1)).save(any(Resource.class)); + verify(resourceRepo, times(1)).saveAndFlush(any(Resource.class)); } /** -- GitLab From 2b198391e58bdb8c5b1013f4643ce2e43f0d3e32 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sun, 12 Jan 2025 18:27:51 +0200 Subject: [PATCH 58/59] fix for _LCM_CHARACTERISTICS_ --- .../tmf/sim638/service/ServiceRepoService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 01b5b31..d4f9afa 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 @@ -577,23 +577,25 @@ public class ServiceRepoService { } - /** - * Check here if the characteristics changed are of interest for LCM rules and further processing by the orchestrator - */ - Characteristic lcmchar = service.getServiceCharacteristicByName("_LCM_CHARACTERISTICS_"); + /** + * 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 - Set setB = new HashSet<>(Arrays.asList(arrayB)); // Check if any value from stra exists in strb boolean valueExists = false; for (String value : arrayA) { - if (setB.contains(value)) { + for (String b : arrayB) { + if ( b.equals(value) ) { valueExists = true; // A common value exists - } + break; + } + } } if (!valueExists) { serviceCharacteristicChanged=false; -- GitLab From f521bdc807e93582c745d69c22153b8d7f7d1fe0 Mon Sep 17 00:00:00 2001 From: trantzas Date: Tue, 14 Jan 2025 13:16:47 +0000 Subject: [PATCH 59/59] Preparing the 2024Q4_RC: - Remove -SNAPSHOT from parent's version at pom.xml - Remove -SNAPSHOT from Dockerfile's jar references --- Dockerfile | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a192566..5d9a1d4 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.1.0-SNAPSHOT-exec.jar /opt/openslice/lib/ -CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.tmf.api-1.1.0-SNAPSHOT-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 1d671cd..3184b3a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.etsi.osl org.etsi.osl.main - 2024Q4-SNAPSHOT + 2024Q4 ../org.etsi.osl.main -- GitLab